public function profile(Request $request)
    {
        $userEntity = $this->getUser();
        if ($userEntity === false) {
            return $this->redirectToRoute('users');
        }

        // Generate the form
        $form = $this->createFormBuilder(FormType\UserProfileType::class, $userEntity)
            ->getForm()
            ->handleRequest($request)
        ;

        if ($form->isSubmitted() && $form->isValid()) {
            /** @var \Bolt\Form\FormType\UserData $data */
            $data = $form->getData();
            $data->applyToEntity($userEntity);

            $this->app['logger.system']->info(Trans::__('page.edit-users.log.user-updated', ['%user%' => $userEntity->getDisplayname()]), ['event' => 'security']);
            if ($this->getRepository(Entity\Users::class)->save($userEntity)) {
                $this->flashes()->success(Trans::__('page.edit-users.message.user-saved', ['%user%' => $userEntity->getDisplayname()]));
            } else {
                $this->flashes()->error(Trans::__('page.edit-users.message.saving-user', ['%user%' => $userEntity->getDisplayname()]));
            }

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

        $context = [
            'kind'        => 'profile',
            'form'        => $form->createView(),
            'note'        => '',
            'displayname' => $userEntity->getDisplayname(),
        ];

        return $this->render('@bolt/edituser/edituser.twig', $context);
    }
public function profile(Request $request)
    {
        $userEntity = $this->getUser();
        if ($userEntity === false) {
            return $this->redirectToRoute('users');
        }

        // Generate the form
        $form = $this->createFormBuilder(FormType\UserProfileType::class, $userEntity)
            ->getForm()
            ->handleRequest($request)
        ;

        if ($form->isSubmitted() && $form->isValid()) {
            /** @var \Bolt\Form\FormType\UserData $data */
            $data = $form->getData();
            $data->applyToEntity($userEntity);

            $this->app['logger.system']->info(Trans::__('page.edit-users.log.user-updated', ['%user%' => $userEntity->getDisplayname()]), ['event' => 'security']);
            if ($this->getRepository(Entity\Users::class)->save($userEntity)) {
                $this->flashes()->success(Trans::__('page.edit-users.message.user-saved', ['%user%' => $userEntity->getDisplayname()]));
            } else {
                $this->flashes()->error(Trans::__('page.edit-users.message.saving-user', ['%user%' => $userEntity->getDisplayname()]));
            }

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

        $context = [
            'kind'        => 'profile',
            'form'        => $form->createView(),
            'note'        => '',
            'displayname' => $userEntity->getDisplayname(),
        ];

        return $this->render('@bolt/edituser/edituser.twig', $context);
    }
public function profile ( Request $ request ) { $ userEntity = $ this -> getUser ( ) ; if ( $ userEntity === false ) { return $ this -> redirectToRoute ( 'users' ) ; } // Generate the form $ form = $ this -> createFormBuilder ( FormType \ UserProfileType :: class , $ userEntity ) -> getForm ( ) -> handleRequest ( $ request ) ; if ( $ form -> isSubmitted ( ) && $ form -> isValid ( ) ) { /** @var \Bolt\Form\FormType\UserData $data */ $ data = $ form -> getData ( ) ; $ data -> applyToEntity ( $ userEntity ) ; $ this -> app [ 'logger.system' ] -> info ( Trans :: __ ( 'page.edit-users.log.user-updated' , [ '%user%' => $ userEntity -> getDisplayname ( ) ] ) , [ 'event' => 'security' ] ) ; if ( $ this -> getRepository ( Entity \ Users :: class ) -> save ( $ userEntity ) ) { $ this -> flashes ( ) -> success ( Trans :: __ ( 'page.edit-users.message.user-saved' , [ '%user%' => $ userEntity -> getDisplayname ( ) ] ) ) ; } else { $ this -> flashes ( ) -> error ( Trans :: __ ( 'page.edit-users.message.saving-user' , [ '%user%' => $ userEntity -> getDisplayname ( ) ] ) ) ; } return $ this -> redirectToRoute ( 'profile' ) ; } $ context = [ 'kind' => 'profile' , 'form' => $ form -> createView ( ) , 'note' => '' , 'displayname' => $ userEntity -> getDisplayname ( ) , ] ; return $ this -> render ( '@bolt/edituser/edituser.twig' , $ context ) ; }
User profile page route.

@param Request $request The Symfony Request

@return \Bolt\Response\TemplateResponse|\Symfony\Component\HttpFoundation\RedirectResponse
User profile page route .