]> git.immae.eu Git - github/wallabag/wallabag.git/blobdiff - src/Wallabag/UserBundle/Mailer/AuthCodeMailer.php
Add a real configuration for CS-Fixer
[github/wallabag/wallabag.git] / src / Wallabag / UserBundle / Mailer / AuthCodeMailer.php
index c04720aeaa52700dcb352a0277f6df769aa34f54..aed805c957c2a37c2a4c6a954e54991d9e2afb9e 100644 (file)
@@ -2,9 +2,8 @@
 
 namespace Wallabag\UserBundle\Mailer;
 
-use Scheb\TwoFactorBundle\Model\Email\TwoFactorInterface;
 use Scheb\TwoFactorBundle\Mailer\AuthCodeMailerInterface;
-use Symfony\Component\Translation\TranslatorInterface;
+use Scheb\TwoFactorBundle\Model\Email\TwoFactorInterface;
 
 /**
  * Custom mailer for TwoFactorBundle email.
@@ -47,22 +46,31 @@ class AuthCodeMailer implements AuthCodeMailerInterface
      */
     private $supportUrl;
 
+    /**
+     * Url for the wallabag instance (only used for image in the HTML email template).
+     *
+     * @var string
+     */
+    private $wallabagUrl;
+
     /**
      * Initialize the auth code mailer with the SwiftMailer object.
      *
-     * @param \Swift_Mailer           $mailer
-     * @param \Twig_Environment       $twig
-     * @param string                  $senderEmail
-     * @param string                  $senderName
-     * @param string                  $supportUrl
+     * @param \Swift_Mailer     $mailer
+     * @param \Twig_Environment $twig
+     * @param string            $senderEmail
+     * @param string            $senderName
+     * @param string            $supportUrl  wallabag support url
+     * @param string            $wallabagUrl wallabag instance url
      */
-    public function __construct(\Swift_Mailer $mailer, \Twig_Environment $twig, $senderEmail, $senderName, $supportUrl)
+    public function __construct(\Swift_Mailer $mailer, \Twig_Environment $twig, $senderEmail, $senderName, $supportUrl, $wallabagUrl)
     {
         $this->mailer = $mailer;
         $this->twig = $twig;
         $this->senderEmail = $senderEmail;
         $this->senderName = $senderName;
         $this->supportUrl = $supportUrl;
+        $this->wallabagUrl = $wallabagUrl;
     }
 
     /**
@@ -72,18 +80,19 @@ class AuthCodeMailer implements AuthCodeMailerInterface
      */
     public function sendAuthCode(TwoFactorInterface $user)
     {
-        $template = $this->twig->loadTemplate('@WallabagUserBundle/Resources/views/TwoFactor/email_auth_code.html.twig');
+        $template = $this->twig->loadTemplate('WallabagUserBundle:TwoFactor:email_auth_code.html.twig');
 
-        $subject  = $template->renderBlock('subject', array());
+        $subject = $template->renderBlock('subject', []);
         $bodyHtml = $template->renderBlock('body_html', [
             'user' => $user->getName(),
             'code' => $user->getEmailAuthCode(),
-            'support' => $this->supportUrl,
+            'support_url' => $this->supportUrl,
+            'wallabag_url' => $this->wallabagUrl,
         ]);
         $bodyText = $template->renderBlock('body_text', [
             'user' => $user->getName(),
             'code' => $user->getEmailAuthCode(),
-            'support' => $this->supportUrl,
+            'support_url' => $this->supportUrl,
         ]);
 
         $message = new \Swift_Message();