src/PN/Bundle/CMSBundle/Controller/Administration/ServiceController.php
/**
     * Displays a form to edit an existing service entity.
     *
     * @Route("/{id}/edit", name="service_edit",methods={"GET", "POST"})
     */
Displays a form to edit an existing service entity.
Displays a form to edit an existing service entity .
public function editAction(Request $request, Service $service) {
        $this->denyAccessUnlessGranted('ROLE_ADMIN');
        $em = $this->getDoctrine()->getManager();
        $form = $this->createForm(ServiceType::class, $service);
        $form->handleRequest($request);
        if ($form->isSubmitted() && $form->isValid()) {
            $userName = $this->get('user')->getUserName();
            $service->setModifiedBy($userName);
            $em->flush();
            $this->addFlash('success', 'Successfully updated');
            return $this->redirectToRoute('service_edit', array('id' => $service->getId()));
        }
        return $this->render('cms/admin/service/edit.html.twig', array(
                    'service' => $service,
                    'form' => $form->createView(),
        ));
    }
public function editAction ( Request $ request , Service $ service ) { $ this -> denyAccessUnlessGranted ( 'ROLE_ADMIN' ) ; $ em = $ this -> getDoctrine ( ) -> getManager ( ) ; $ form = $ this -> createForm ( ServiceType :: class , $ service ) ; $ form -> handleRequest ( $ request ) ; if ( $ form -> isSubmitted ( ) && $ form -> isValid ( ) ) { $ userName = $ this -> get ( 'user' ) -> getUserName ( ) ; $ service -> setModifiedBy ( $ userName ) ; $ em -> flush ( ) ; $ this -> addFlash ( 'success' , 'Successfully updated' ) ; return $ this -> redirectToRoute ( 'service_edit' , array ( 'id' => $ service -> getId ( ) ) ) ; } return $ this -> render ( 'cms/admin/service/edit.html.twig' , array ( 'service' => $ service , 'form' => $ form -> createView ( ) , ) ) ; }
Displays a form to edit an existing service entity.
Displays a form to edit an existing service entity .