/** * @return FormInterface */ public function createForm() { $user = $this->userDiscriminator->getCurrentUserConfig(); $type = $user->getFormType($this->type); $name = $user->getFormName($this->type); $validationGroups = $user->getFormValidationGroups($this->type); return $this->formFactory->createNamed($name, $type, null, array('validation_groups' => $validationGroups)); }
public function onRegistrationSuccess(FormEvent $event) { if (!$this->userDiscriminator->getCurrentUserConfig()->getConfig('registering.confirmation.enabled', false)) { return; } /** @var $user \FOS\UserBundle\Model\UserInterface */ $user = $event->getForm()->getData(); $user->setEnabled(false); if (null === $user->getConfirmationToken()) { $user->setConfirmationToken($this->tokenGenerator->generateToken()); } $this->mailer->sendConfirmationEmailMessage($user); $this->session->set('fos_user_send_confirmation_email/email', $user->getEmail()); $url = $this->router->generate($this->userDiscriminator->getCurrentUserConfig()->getRoutePrefix() . '_registration_check_email'); $event->setResponse(new RedirectResponse($url)); }
/** * This must be called on prePersist and preUpdate if the event is about a * user. * * @param UserInterface $user */ protected function updateUserFields(UserInterface $user) { if (null === $this->userDiscriminator) { $this->userDiscriminator = $this->container->get('rollerworks_multi_user.user_discriminator'); } // Can only use the user manager when there is an user-system active if (null === $this->userDiscriminator->getCurrentUser() || true !== $this->userDiscriminator->getCurrentUserConfig()->getConfig('use_listener', true)) { return; } if (null === $this->userManager) { $this->userManager = $this->container->get('fos_user.user_manager'); } $this->userManager->updateCanonicalFields($user); $this->userManager->updatePassword($user); }