/**
* @Route("/register", name="register")
* @Template()
*/
public function registerAction(Request $request)
{
if ($request->getMethod() == 'POST') {
$manager = $this->getDoctrine()->getManager();
$user = new User();
$user->setUsername($request->request->get('username'));
$user->setSalt(md5(time()));
$encoder = new MessageDigestPasswordEncoder('sha512', true, 10);
$password = $encoder->encodePassword($request->request->get('password'), $user->getSalt());
$user->setPassword($password);
$user->setRoles('ROLE_UNCONFIRMED');
$user->setLastName($request->request->get('lastName'));
$user->setFirstName($request->request->get('firstName'));
$user->setSurName('');
$user->setPhone($request->request->get('phone'));
$user->setCompany($request->request->get('companyTitle'));
$manager->persist($user);
$manager->flush($user);
$manager->refresh($user);
$session = new Session();
$session->getFlashBag()->add('success', 'Ваша заявка принята. Пожалуйста, ожидайте подтверждения регистрации на указанный электронный адрес');
@$this->get('email.service')->send(array($user->getUsername()), array('AppBundle:Email:registerNotifyUser.html.twig'), 'Сообщение от navigator mediaFirst');
@$this->get('email.service')->send(array('*****@*****.**', '*****@*****.**', '*****@*****.**'), array('AppBundle:Email:registerNotify.html.twig'), 'Сообщение от navigator mediaFirst');
return $this->redirect($this->generateUrl('homepage'));
}
return array();
}