mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-07 18:44:08 +00:00
remove Mailer, add SwiftMailer, fix password recover request
This commit is contained in:
parent
01e93f7ba3
commit
2fee88bfce
@ -27,42 +27,47 @@ use Chill\MainBundle\Security\PasswordRecover\PasswordRecoverVoter;
|
|||||||
*/
|
*/
|
||||||
class PasswordController extends AbstractController
|
class PasswordController extends AbstractController
|
||||||
{
|
{
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @var UserPasswordEncoderInterface
|
* @var UserPasswordEncoderInterface
|
||||||
*/
|
*/
|
||||||
protected $passwordEncoder;
|
protected $passwordEncoder;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @var TranslatorInterface
|
* @var TranslatorInterface
|
||||||
*/
|
*/
|
||||||
protected $translator;
|
protected $translator;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @var LoggerInterface
|
* @var LoggerInterface
|
||||||
*/
|
*/
|
||||||
protected $chillLogger;
|
protected $chillLogger;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @var RecoverPasswordHelper
|
* @var RecoverPasswordHelper
|
||||||
*/
|
*/
|
||||||
protected $recoverPasswordHelper;
|
protected $recoverPasswordHelper;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @var TokenManager
|
* @var TokenManager
|
||||||
*/
|
*/
|
||||||
protected $tokenManager;
|
protected $tokenManager;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @var EventDispatcherInterface
|
* @var EventDispatcherInterface
|
||||||
*/
|
*/
|
||||||
protected $eventDispatcher;
|
protected $eventDispatcher;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* PasswordController constructor.
|
||||||
|
*
|
||||||
|
* @param LoggerInterface $chillLogger
|
||||||
|
* @param UserPasswordEncoderInterface $passwordEncoder
|
||||||
|
* @param RecoverPasswordHelper $recoverPasswordHelper
|
||||||
|
* @param TokenManager $tokenManager
|
||||||
|
* @param TranslatorInterface $translator
|
||||||
|
* @param EventDispatcherInterface $eventDispatcher
|
||||||
|
*/
|
||||||
public function __construct(
|
public function __construct(
|
||||||
LoggerInterface $chillLogger,
|
LoggerInterface $chillLogger,
|
||||||
UserPasswordEncoderInterface $passwordEncoder,
|
UserPasswordEncoderInterface $passwordEncoder,
|
||||||
@ -80,7 +85,6 @@ class PasswordController extends AbstractController
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @param Request $request
|
* @param Request $request
|
||||||
* @return Response
|
* @return Response
|
||||||
*/
|
*/
|
||||||
@ -128,8 +132,6 @@ class PasswordController extends AbstractController
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
*
|
|
||||||
* @param User $user
|
* @param User $user
|
||||||
* @return \Symfony\Component\Form\Form
|
* @return \Symfony\Component\Form\Form
|
||||||
*/
|
*/
|
||||||
@ -145,7 +147,10 @@ class PasswordController extends AbstractController
|
|||||||
;
|
;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param Request $request
|
||||||
|
* @return \Symfony\Component\HttpFoundation\RedirectResponse|Response
|
||||||
|
*/
|
||||||
public function recoverAction(Request $request)
|
public function recoverAction(Request $request)
|
||||||
{
|
{
|
||||||
if (FALSE === $this->isGranted(PasswordRecoverVoter::ASK_TOKEN)) {
|
if (FALSE === $this->isGranted(PasswordRecoverVoter::ASK_TOKEN)) {
|
||||||
@ -205,11 +210,20 @@ class PasswordController extends AbstractController
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return Response
|
||||||
|
*/
|
||||||
public function changeConfirmedAction()
|
public function changeConfirmedAction()
|
||||||
{
|
{
|
||||||
return $this->render('@ChillMain/Password/recover_password_changed.html.twig');
|
return $this->render('@ChillMain/Password/recover_password_changed.html.twig');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param Request $request
|
||||||
|
* @return \Symfony\Component\HttpFoundation\RedirectResponse|Response
|
||||||
|
* @throws \Doctrine\ORM\NoResultException
|
||||||
|
* @throws \Doctrine\ORM\NonUniqueResultException
|
||||||
|
*/
|
||||||
public function requestRecoverAction(Request $request)
|
public function requestRecoverAction(Request $request)
|
||||||
{
|
{
|
||||||
if (FALSE === $this->isGranted(PasswordRecoverVoter::ASK_TOKEN)) {
|
if (FALSE === $this->isGranted(PasswordRecoverVoter::ASK_TOKEN)) {
|
||||||
@ -277,11 +291,17 @@ class PasswordController extends AbstractController
|
|||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return Response
|
||||||
|
*/
|
||||||
public function requestRecoverConfirmAction()
|
public function requestRecoverConfirmAction()
|
||||||
{
|
{
|
||||||
return $this->render('@ChillMain/Password/request_recover_password_confirm.html.twig');
|
return $this->render('@ChillMain/Password/request_recover_password_confirm.html.twig');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return \Symfony\Component\Form\FormInterface
|
||||||
|
*/
|
||||||
protected function requestRecoverForm()
|
protected function requestRecoverForm()
|
||||||
{
|
{
|
||||||
$builder = $this->createFormBuilder();
|
$builder = $this->createFormBuilder();
|
||||||
|
@ -22,13 +22,15 @@ use Psr\Log\LoggerInterface;
|
|||||||
use Symfony\Component\Mailer\MailerInterface;
|
use Symfony\Component\Mailer\MailerInterface;
|
||||||
use Symfony\Component\Routing\RouterInterface;
|
use Symfony\Component\Routing\RouterInterface;
|
||||||
use Symfony\Component\Translation\TranslatorInterface;
|
use Symfony\Component\Translation\TranslatorInterface;
|
||||||
|
use Twig\Environment;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Class Mailer
|
||||||
* Classe d'aide pour l'envoi de notification.
|
* Classe d'aide pour l'envoi de notification.
|
||||||
*
|
*
|
||||||
* Héberge toutes les méthodes pour ré-écrire les URL en fonction de la langue
|
* Héberge toutes les méthodes pour ré-écrire les URL en fonction de la langue de l'utilisateur.
|
||||||
* de l'utilisateur.
|
|
||||||
*
|
*
|
||||||
|
* @package Chill\MainBundle\Notification
|
||||||
*/
|
*/
|
||||||
class Mailer
|
class Mailer
|
||||||
{
|
{
|
||||||
@ -38,45 +40,49 @@ class Mailer
|
|||||||
protected $logger;
|
protected $logger;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @var \Twig\Environment
|
* @var \Twig\Environment
|
||||||
*/
|
*/
|
||||||
protected $twig;
|
protected $twig;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @var \Swift_Mailer
|
* @var \Swift_Mailer
|
||||||
*/
|
*/
|
||||||
protected $mailer;
|
protected $mailer;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @var \Swift_Mailer
|
* @var \Swift_Mailer
|
||||||
*/
|
*/
|
||||||
protected $forcedMailer;
|
protected $forcedMailer;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @var RouterInterface
|
* @var RouterInterface
|
||||||
*/
|
*/
|
||||||
protected $router;
|
protected $router;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @var TranslatorInterface
|
* @var TranslatorInterface
|
||||||
*/
|
*/
|
||||||
protected $translator;
|
protected $translator;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @var array
|
* @var array
|
||||||
*/
|
*/
|
||||||
protected $routeParameters;
|
protected $routeParameters;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Mailer constructor.
|
||||||
|
*
|
||||||
|
* @param LoggerInterface $logger
|
||||||
|
* @param Environment $twig
|
||||||
|
* @param \Swift_Mailer $mailer
|
||||||
|
* @param RouterInterface $router
|
||||||
|
* @param TranslatorInterface $translator
|
||||||
|
* @param $routeParameters
|
||||||
|
*/
|
||||||
public function __construct(
|
public function __construct(
|
||||||
LoggerInterface $logger,
|
LoggerInterface $logger,
|
||||||
\Twig\Environment $twig,
|
Environment $twig,
|
||||||
MailerInterface $mailer,
|
\Swift_Mailer $mailer,
|
||||||
// due to bug https://github.com/symfony/swiftmailer-bundle/issues/127
|
// due to bug https://github.com/symfony/swiftmailer-bundle/issues/127
|
||||||
// \Swift_Transport $mailerTransporter,
|
// \Swift_Transport $mailerTransporter,
|
||||||
RouterInterface $router,
|
RouterInterface $router,
|
||||||
@ -86,13 +92,12 @@ class Mailer
|
|||||||
$this->logger = $logger;
|
$this->logger = $logger;
|
||||||
$this->twig = $twig;
|
$this->twig = $twig;
|
||||||
$this->mailer = $mailer;
|
$this->mailer = $mailer;
|
||||||
|
//$this->forcedMailer = new \Swift_Mailer($mailerTransporter);
|
||||||
$this->router = $router;
|
$this->router = $router;
|
||||||
$this->translator = $translator;
|
$this->translator = $translator;
|
||||||
$this->routeParameters = $routeParameters;
|
$this->routeParameters = $routeParameters;
|
||||||
//$this->forcedMailer = new \Swift_Mailer($mailerTransporter);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Envoie une notification à un utilisateur.
|
* Envoie une notification à un utilisateur.
|
||||||
*
|
*
|
||||||
@ -140,6 +145,11 @@ class Mailer
|
|||||||
$this->sendMessage($message, $force);
|
$this->sendMessage($message, $force);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param \Swift_Message $message
|
||||||
|
* @param $force
|
||||||
|
* @throws \Symfony\Component\Mailer\Exception\TransportExceptionInterface
|
||||||
|
*/
|
||||||
public function sendMessage(\Swift_Message $message, $force)
|
public function sendMessage(\Swift_Message $message, $force)
|
||||||
{
|
{
|
||||||
if ($force) {
|
if ($force) {
|
||||||
@ -149,6 +159,15 @@ class Mailer
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param User $to
|
||||||
|
* @param $template
|
||||||
|
* @param array $parameters
|
||||||
|
* @return string
|
||||||
|
* @throws \Twig\Error\LoaderError
|
||||||
|
* @throws \Twig\Error\RuntimeError
|
||||||
|
* @throws \Twig\Error\SyntaxError
|
||||||
|
*/
|
||||||
public function renderContentToUser(User $to, $template, array $parameters = array())
|
public function renderContentToUser(User $to, $template, array $parameters = array())
|
||||||
{
|
{
|
||||||
$context = $this->router->getContext();
|
$context = $this->router->getContext();
|
||||||
|
@ -1,10 +1,10 @@
|
|||||||
services:
|
services:
|
||||||
Chill\MainBundle\Notification\Mailer:
|
Chill\MainBundle\Notification\Mailer:
|
||||||
arguments:
|
arguments:
|
||||||
- "@logger"
|
$logger: '@Psr\Log\LoggerInterface'
|
||||||
- "@twig"
|
$twig: '@Twig\Environment'
|
||||||
- "@mailer"
|
$mailer: '@swiftmailer.mailer.default'
|
||||||
# - "@swiftmailer.transport"
|
# $mailerTransporter: '@swiftmailer.transport'
|
||||||
- "@router"
|
$router: '@Symfony\Component\Routing\RouterInterface'
|
||||||
- "@translator"
|
$translator: '@Symfony\Component\Translation\TranslatorInterface'
|
||||||
- "%chill_main.notifications%"
|
$routeParameters: '%chill_main.notifications%'
|
||||||
|
Loading…
x
Reference in New Issue
Block a user