Материал: Автоматизация управления проектами в студии APPCRAFT

Внимание! Если размещение файла нарушает Ваши авторские права, то обязательно сообщите нам
124
<br />
Только что Вы запросили новый пароль <a
href='delfa72.ru'>на сайте учебного центра Дельфа</a>.<br />
</td>
</tr>
<tr>
<td style='text-align:left;'>
<br />
Ваши данные для входа на сайт: <br />
Имя пользователя: %login%<br />
Пароль: %password%<br />
</td>
</tr>
<tr>
<td style='text-align:left;color:#222;font-size:18px;'>
<br />
<hr>
</td>
</tr>
</table>
</div>
</body>
</html>\"
";
$body = preg_replace('/%login%/',$user-
>getUsername(), $body); //заменяем выражения
$body = preg_replace('/%password%/',$userpassword,
$body); //заменяем выражения
$emails = $user->getEmail();
/** @var \Swift_Mailer $mailer */
$mailer = $this->get('mailer');
$message = $mailer->createMessage()
125
->setSubject('Восстановление пароля')
-
>setFrom(array('noreply@'.$_SERVER['SERVER_NAME'] => 'УЦ Дельфа'))
->setTo($emails)
->setBody($body, 'text/html');
$mailer->send($message);
return $this-
>redirectToRoute('site_general_remindpasswordsuccess');
}
}
$this->navigation = array('active' => 'remindpassword');
$this->forms['user'] = $form->createView();
return $this-
>render('AppBundle:Security:remindpassword.html.twig');
}
//страница с инстукцией по проверке почты, на которую был выслан
новый пароль
/**
* @return Response
* @Config\Route("/remindpasswordok", name =
"site_general_remindpasswordsuccess")
*/
public function remindpasswordsuccessAction()
{
$this->navigation = array('active' => 'remindpassword');
return $this-
>render('AppBundle:Security:remindpasswordok.html.twig');
}
126
}
<?php
namespace AppBundle\Controller;
use AppBundle\Entity\User;
use Doctrine\ORM\EntityManager;
use Doctrine\ORM\EntityRepository;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpFoundation\Session\Session;
use
Symfony\Component\Security\Core\Authorization\AuthorizationChecker
;
abstract class InitializableController extends Controller
{
/** @var AuthorizationChecker */
protected $authChecker;
/** @var array */
protected $forms;
/** @var EntityManager */
protected $manager;
/** @var array|EntityRepository[] */
protected $repositories;
/** @var Request */
protected $request;
/** @var Session */
protected $session;
/** @var User */
protected $user;
/** @var array */
protected $view;
127
/** @var array */
protected $navigation;
/**
* @param string $level
* @param string $view
* @param array $parameters
*/
public function addNotice($level, $view, array $parameters =
array())
{
$this->get('session')->getFlashBag()->add(
'notice.' . $level,
$this->renderView('AppBundle:Notice:' . $view,
$parameters)
);
}
/**
* @param $entity
* @return EntityRepository
*/
public function getRepository($entity)
{
if (!array_key_exists($entity, $this->repositories))
$this->repositories[$entity] = $this->manager-
>getRepository('AppBundle:' . $entity);
return $this->repositories[$entity];
}
128
public function initialize(Request $request)
{
$this->request = $request;
$this->authChecker = $this-
>get('security.authorization_checker');
$this->forms = array();
$this->navigation = array();
$this->manager = $this->getDoctrine()->getManager();
$this->repositories = array();
$this->session = $this->request->getSession();
$this->user = $this->getUser();
$this->view = array();
}
/**
* @param string $view
* @param array $parameters
* @param Response $response
* @return Response
*/
public function render($view, array $parameters = array(),
Response $response = null)
{
$parameters = array_merge($parameters, array(
'forms' => $this->forms,
'view' => $this->view,
'navigation'=>$this->navigation
));
return parent::render($view, $parameters, $response);
Источник: https://baza.diplomsite.ru/previewfile/2299