/** * {@inheritDoc} */ public function getId() { if ($this->__isInitialized__ === false) { return (int) parent::getId(); } $this->__initializer__ && $this->__initializer__->__invoke($this, 'getId', array()); return parent::getId(); }
public function registerUser(User $User) { if (null !== $User->getId()) { throw new UserException('Użytkownik jest już zarejestrowany'); } $encoder = $this->encoderFactory->getEncoder($User); $encoderPasswd = $encoder->encodePassword($User->getPlainPassword(), $User->getSalt()); $User->setPassword($encoderPasswd); $User->setActionToken($this->generateActionToken()); $User->setEnabled(false); $em = $this->doctrine->getManager(); $em->persist($User); $em->flush(); $urlParams = array('actionToken' => $User->getActionToken()); $activationUrl = $this->router->generate('user_activateAccount', $urlParams, UrlGeneratorInterface::ABSOLUTE_URL); $emailBody = $this->templating->render('CommonUserBundle:Email:accountActivation.html.twig', array('activationUrl' => $activationUrl)); $this->userMailer->send($User, 'Aktywacja konta', $emailBody); return true; }