12345678910111213141516171819202122232425262728293031323334 |
- <?php
- namespace Packagist\WebBundle\Controller;
- use FOS\UserBundle\Controller\ProfileController as BaseController;
- use FOS\UserBundle\Model\UserInterface;
- use Symfony\Component\HttpFoundation\RedirectResponse;
- use Symfony\Component\Security\Core\Exception\AccessDeniedException;
- class ProfileController extends BaseController
- {
- public function editAction()
- {
- $user = $this->container->get('security.context')->getToken()->getUser();
- if (!is_object($user) || !$user instanceof UserInterface) {
- throw new AccessDeniedException('This user does not have access to this section.');
- }
- $form = $this->container->get('fos_user.profile.form');
- $formHandler = $this->container->get('fos_user.profile.form.handler');
- $process = $formHandler->process($user);
- if ($process) {
- $this->setFlash('fos_user_success', 'profile.flash.updated');
- return new RedirectResponse($this->getRedirectionUrl($user));
- }
- return $this->container->get('templating')->renderResponse(
- 'FOSUserBundle:Profile:edit.html.'.$this->container->getParameter('fos_user.template.engine'),
- array('form' => $form->createView(), 'user' => $user)
- );
- }
- }
|