Bundle/BusinessPageBundle/Controller/BusinessTemplateController.php
public function updateAction(Request $request, $id)
    {
        $em = $this->getDoctrine()->getManager();

        /** @var BusinessTemplate $pagePattern */
        $pagePattern = $em->getRepository('VictoireBusinessPageBundle:BusinessTemplate')->find($id);

        if (!$pagePattern) {
            throw $this->createNotFoundException('Unable to find BusinessTemplate entity.');
        }

        $editForm = $this->createEditForm($pagePattern);
        $editForm->handleRequest($request);

        if ($editForm->isValid()) {
            $em->flush();

            //redirect to the page of the template
            $completeUrl = $this->generateUrl('victoire_business_template_show', ['id' => $pagePattern->getId()]);
            $message = $this->get('translator')->trans('victoire.business_template.edit.success', [], 'victoire');

            $success = true;
        } else {
            $success = false;
            $completeUrl = null;
            $message = $this->get('translator')->trans('victoire.business_template.edit.error', [], 'victoire');
        }

        return new JsonResponse([
            'success' => $success,
            'url'     => $completeUrl,
            'message' => $message,
        ]);
    }
public function updateAction(Request $request, $id)
    {
        $em = $this->getDoctrine()->getManager();

        /** @var BusinessTemplate $pagePattern */
        $pagePattern = $em->getRepository('VictoireBusinessPageBundle:BusinessTemplate')->find($id);

        if (!$pagePattern) {
            throw $this->createNotFoundException('Unable to find BusinessTemplate entity.');
        }

        $editForm = $this->createEditForm($pagePattern);
        $editForm->handleRequest($request);

        if ($editForm->isValid()) {
            $em->flush();

            //redirect to the page of the template
            $completeUrl = $this->generateUrl('victoire_business_template_show', ['id' => $pagePattern->getId()]);
            $message = $this->get('translator')->trans('victoire.business_template.edit.success', [], 'victoire');

            $success = true;
        } else {
            $success = false;
            $completeUrl = null;
            $message = $this->get('translator')->trans('victoire.business_template.edit.error', [], 'victoire');
        }

        return new JsonResponse([
            'success' => $success,
            'url'     => $completeUrl,
            'message' => $message,
        ]);
    }
public function updateAction ( Request $ request , $ id ) { $ em = $ this -> getDoctrine ( ) -> getManager ( ) ; /** @var BusinessTemplate $pagePattern */ $ pagePattern = $ em -> getRepository ( 'VictoireBusinessPageBundle:BusinessTemplate' ) -> find ( $ id ) ; if ( ! $ pagePattern ) { throw $ this -> createNotFoundException ( 'Unable to find BusinessTemplate entity.' ) ; } $ editForm = $ this -> createEditForm ( $ pagePattern ) ; $ editForm -> handleRequest ( $ request ) ; if ( $ editForm -> isValid ( ) ) { $ em -> flush ( ) ; //redirect to the page of the template $ completeUrl = $ this -> generateUrl ( 'victoire_business_template_show' , [ 'id' => $ pagePattern -> getId ( ) ] ) ; $ message = $ this -> get ( 'translator' ) -> trans ( 'victoire.business_template.edit.success' , [ ] , 'victoire' ) ; $ success = true ; } else { $ success = false ; $ completeUrl = null ; $ message = $ this -> get ( 'translator' ) -> trans ( 'victoire.business_template.edit.error' , [ ] , 'victoire' ) ; } return new JsonResponse ( [ 'success' => $ success , 'url' => $ completeUrl , 'message' => $ message , ] ) ; }
Edits an existing BusinessTemplate entity.

@param Request $request
@param string  $id

@Route("/{id}", name="victoire_business_template_update")
@Method("PUT")

@throws \Exception

@return JsonResponse The parameter for the response
Edits an existing BusinessTemplate entity .