public function editAction(Request $request, $id)
    {
        $em = $this->getDoctrine()->getManager();
        $user = $em->getRepository('OpiferCmsBundle:User')->find($id);

        $form = $this->createForm(UserFormType::class, $user);
        $form->handleRequest($request);

        if ($form->isValid()) {

            if ($user->isTwoFactorEnabled() == false) {
                $user->setGoogleAuthenticatorSecret(null);
            }

            $this->get('fos_user.user_manager')->updateUser($user, true);

            $this->addFlash('success', $this->get('translator')->trans('user.edit.success', [
                '%username%' => ucfirst($user->getUsername()),
            ]));

            return $this->redirectToRoute('opifer_cms_user_index');
        }

        return $this->render('OpiferCmsBundle:Backend/User:edit.html.twig', [
            'form' => $form->createView(),
            'user' => $user,
        ]);
    }
public function editAction(Request $request, $id)
    {
        $em = $this->getDoctrine()->getManager();
        $user = $em->getRepository('OpiferCmsBundle:User')->find($id);

        $form = $this->createForm(UserFormType::class, $user);
        $form->handleRequest($request);

        if ($form->isValid()) {

            if ($user->isTwoFactorEnabled() == false) {
                $user->setGoogleAuthenticatorSecret(null);
            }

            $this->get('fos_user.user_manager')->updateUser($user, true);

            $this->addFlash('success', $this->get('translator')->trans('user.edit.success', [
                '%username%' => ucfirst($user->getUsername()),
            ]));

            return $this->redirectToRoute('opifer_cms_user_index');
        }

        return $this->render('OpiferCmsBundle:Backend/User:edit.html.twig', [
            'form' => $form->createView(),
            'user' => $user,
        ]);
    }
public function editAction ( Request $ request , $ id ) { $ em = $ this -> getDoctrine ( ) -> getManager ( ) ; $ user = $ em -> getRepository ( 'OpiferCmsBundle:User' ) -> find ( $ id ) ; $ form = $ this -> createForm ( UserFormType :: class , $ user ) ; $ form -> handleRequest ( $ request ) ; if ( $ form -> isValid ( ) ) { if ( $ user -> isTwoFactorEnabled ( ) == false ) { $ user -> setGoogleAuthenticatorSecret ( null ) ; } $ this -> get ( 'fos_user.user_manager' ) -> updateUser ( $ user , true ) ; $ this -> addFlash ( 'success' , $ this -> get ( 'translator' ) -> trans ( 'user.edit.success' , [ '%username%' => ucfirst ( $ user -> getUsername ( ) ) , ] ) ) ; return $ this -> redirectToRoute ( 'opifer_cms_user_index' ) ; } return $ this -> render ( 'OpiferCmsBundle:Backend/User:edit.html.twig' , [ 'form' => $ form -> createView ( ) , 'user' => $ user , ] ) ; }
Edit a user.

@param Request $request
@param int     $id

@return Response
Edit a user .