Bundle/BusinessPageBundle/Controller/BusinessTemplateController.php
public function createAction(Request $request, $id)
    {
        //get the business entity
        $businessEntity = $this->getBusinessEntity($id);

        /** @var BusinessTemplate $view */
        $view = $this->get('victoire_business_page.BusinessTemplate_chain')->getBusinessTemplate($id);
        $view->setBusinessEntityId($businessEntity->getId());

        $form = $this->createCreateForm($view);

        $form->handleRequest($request);

        $params = [
            'success' => false,
        ];

        if ($form->isValid()) {
            $em = $this->getDoctrine()->getManager();
            $em->persist($view);
            $em->flush();

            //redirect to the page of the pagePattern
            $params['url'] = $this->generateUrl('victoire_business_template_show', ['id' => $view->getId()]);
            $params['success'] = true;

            $this->congrat($this->get('translator')->trans('victoire.business_template.create.success', [], 'victoire'));
        } else {
            //get the errors as a string
            $params['message'] = $this->container->get('victoire_form.error_helper')->getRecursiveReadableErrors($form);
        }

        return new JsonResponse($params);
    }
public function createAction(Request $request, $id)
    {
        //get the business entity
        $businessEntity = $this->getBusinessEntity($id);

        /** @var BusinessTemplate $view */
        $view = $this->get('victoire_business_page.BusinessTemplate_chain')->getBusinessTemplate($id);
        $view->setBusinessEntityId($businessEntity->getId());

        $form = $this->createCreateForm($view);

        $form->handleRequest($request);

        $params = [
            'success' => false,
        ];

        if ($form->isValid()) {
            $em = $this->getDoctrine()->getManager();
            $em->persist($view);
            $em->flush();

            //redirect to the page of the pagePattern
            $params['url'] = $this->generateUrl('victoire_business_template_show', ['id' => $view->getId()]);
            $params['success'] = true;

            $this->congrat($this->get('translator')->trans('victoire.business_template.create.success', [], 'victoire'));
        } else {
            //get the errors as a string
            $params['message'] = $this->container->get('victoire_form.error_helper')->getRecursiveReadableErrors($form);
        }

        return new JsonResponse($params);
    }
public function createAction ( Request $ request , $ id ) { //get the business entity $ businessEntity = $ this -> getBusinessEntity ( $ id ) ; /** @var BusinessTemplate $view */ $ view = $ this -> get ( 'victoire_business_page.BusinessTemplate_chain' ) -> getBusinessTemplate ( $ id ) ; $ view -> setBusinessEntityId ( $ businessEntity -> getId ( ) ) ; $ form = $ this -> createCreateForm ( $ view ) ; $ form -> handleRequest ( $ request ) ; $ params = [ 'success' => false , ] ; if ( $ form -> isValid ( ) ) { $ em = $ this -> getDoctrine ( ) -> getManager ( ) ; $ em -> persist ( $ view ) ; $ em -> flush ( ) ; //redirect to the page of the pagePattern $ params [ 'url' ] = $ this -> generateUrl ( 'victoire_business_template_show' , [ 'id' => $ view -> getId ( ) ] ) ; $ params [ 'success' ] = true ; $ this -> congrat ( $ this -> get ( 'translator' ) -> trans ( 'victoire.business_template.create.success' , [ ] , 'victoire' ) ) ; } else { //get the errors as a string $ params [ 'message' ] = $ this -> container -> get ( 'victoire_form.error_helper' ) -> getRecursiveReadableErrors ( $ form ) ; } return new JsonResponse ( $ params ) ; }
Creates a new BusinessTemplate entity.

@param Request $request
@param int     $id

@throws \Exception

@Route("{id}/create", name="victoire_business_template_create")
@Method("POST")

@return JsonResponse
Creates a new BusinessTemplate entity .