diff --git a/Controller/PasswordController.php b/Controller/PasswordController.php index 6d364f7ce..a5cab5b9f 100644 --- a/Controller/PasswordController.php +++ b/Controller/PasswordController.php @@ -27,42 +27,47 @@ use Chill\MainBundle\Security\PasswordRecover\PasswordRecoverVoter; */ class PasswordController extends AbstractController { + /** - * * @var UserPasswordEncoderInterface */ protected $passwordEncoder; /** - * * @var TranslatorInterface */ protected $translator; /** - * * @var LoggerInterface */ protected $chillLogger; /** - * * @var RecoverPasswordHelper */ protected $recoverPasswordHelper; /** - * * @var TokenManager */ protected $tokenManager; /** - * * @var EventDispatcherInterface */ 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( LoggerInterface $chillLogger, UserPasswordEncoderInterface $passwordEncoder, @@ -80,7 +85,6 @@ class PasswordController extends AbstractController } /** - * * @param Request $request * @return Response */ @@ -128,8 +132,6 @@ class PasswordController extends AbstractController } /** - * - * * @param User $user * @return \Symfony\Component\Form\Form */ @@ -144,8 +146,11 @@ class PasswordController extends AbstractController ->add('submit', SubmitType::class, array('label' => 'Change password')) ; } - - + + /** + * @param Request $request + * @return \Symfony\Component\HttpFoundation\RedirectResponse|Response + */ public function recoverAction(Request $request) { if (FALSE === $this->isGranted(PasswordRecoverVoter::ASK_TOKEN)) { @@ -205,11 +210,20 @@ class PasswordController extends AbstractController } + /** + * @return Response + */ public function changeConfirmedAction() { 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) { if (FALSE === $this->isGranted(PasswordRecoverVoter::ASK_TOKEN)) { @@ -277,11 +291,17 @@ class PasswordController extends AbstractController ]); } + /** + * @return Response + */ public function requestRecoverConfirmAction() { return $this->render('@ChillMain/Password/request_recover_password_confirm.html.twig'); } + /** + * @return \Symfony\Component\Form\FormInterface + */ protected function requestRecoverForm() { $builder = $this->createFormBuilder(); diff --git a/Notification/Mailer.php b/Notification/Mailer.php index 3f83f6289..82d8822af 100644 --- a/Notification/Mailer.php +++ b/Notification/Mailer.php @@ -22,13 +22,15 @@ use Psr\Log\LoggerInterface; use Symfony\Component\Mailer\MailerInterface; use Symfony\Component\Routing\RouterInterface; use Symfony\Component\Translation\TranslatorInterface; +use Twig\Environment; /** + * Class Mailer * Classe d'aide pour l'envoi de notification. * - * Héberge toutes les méthodes pour ré-écrire les URL en fonction de la langue - * de l'utilisateur. + * Héberge toutes les méthodes pour ré-écrire les URL en fonction de la langue de l'utilisateur. * + * @package Chill\MainBundle\Notification */ class Mailer { @@ -38,45 +40,49 @@ class Mailer protected $logger; /** - * * @var \Twig\Environment */ protected $twig; /** - * * @var \Swift_Mailer */ protected $mailer; /** - * * @var \Swift_Mailer */ protected $forcedMailer; /** - * * @var RouterInterface */ protected $router; /** - * * @var TranslatorInterface */ protected $translator; /** - * * @var array */ 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( LoggerInterface $logger, - \Twig\Environment $twig, - MailerInterface $mailer, + Environment $twig, + \Swift_Mailer $mailer, // due to bug https://github.com/symfony/swiftmailer-bundle/issues/127 // \Swift_Transport $mailerTransporter, RouterInterface $router, @@ -86,12 +92,11 @@ class Mailer $this->logger = $logger; $this->twig = $twig; $this->mailer = $mailer; + //$this->forcedMailer = new \Swift_Mailer($mailerTransporter); $this->router = $router; $this->translator = $translator; $this->routeParameters = $routeParameters; - //$this->forcedMailer = new \Swift_Mailer($mailerTransporter); } - /** * Envoie une notification à un utilisateur. @@ -140,6 +145,11 @@ class Mailer $this->sendMessage($message, $force); } + /** + * @param \Swift_Message $message + * @param $force + * @throws \Symfony\Component\Mailer\Exception\TransportExceptionInterface + */ public function sendMessage(\Swift_Message $message, $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()) { $context = $this->router->getContext(); diff --git a/config/services/notification.yaml b/config/services/notification.yaml index aee2b79f5..fa4fa15c6 100644 --- a/config/services/notification.yaml +++ b/config/services/notification.yaml @@ -1,10 +1,10 @@ services: Chill\MainBundle\Notification\Mailer: arguments: - - "@logger" - - "@twig" - - "@mailer" - # - "@swiftmailer.transport" - - "@router" - - "@translator" - - "%chill_main.notifications%" + $logger: '@Psr\Log\LoggerInterface' + $twig: '@Twig\Environment' + $mailer: '@swiftmailer.mailer.default' + # $mailerTransporter: '@swiftmailer.transport' + $router: '@Symfony\Component\Routing\RouterInterface' + $translator: '@Symfony\Component\Translation\TranslatorInterface' + $routeParameters: '%chill_main.notifications%'