예제 #1
0
 /**
  * Manages the part of action when the form is valid.
  *
  * @param \Symfony\Component\HttpFoundation\Request            $request The request
  * @param \Symfony\Component\Form\FormInterface                $form    The form
  * @param \Kreta\Component\User\Model\Interfaces\UserInterface $user    The user
  *
  * @return \Symfony\Component\HttpFoundation\RedirectResponse
  */
 private function manageValidForm(Request $request, FormInterface $form, UserInterface $user)
 {
     $user->setEnabled(true);
     $user->setConfirmationToken(null);
     $dispatcher = $this->get('event_dispatcher');
     $event = new FilterUserResponseEvent($user, $request, new Response());
     $dispatcher->dispatch(FOSUserEvents::REGISTRATION_SUCCESS, new FormEvent($form, $request));
     $this->get('fos_user.user_manager')->updateUser($user);
     $dispatcher->dispatch(FOSUserEvents::REGISTRATION_COMPLETED, $event);
     if (!$this->getUser() instanceof UserInterface) {
         throw new AccessDeniedException('This user does not have access to this section.');
     }
     $dispatcher->dispatch(AuthorizationEvent::NAME, new AuthorizationEvent($request));
     return $this->redirect($this->generateUrl('kreta_web_homepage'));
 }