X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=src%2FWallabag%2FUserBundle%2FMailer%2FAuthCodeMailer.php;h=ca9d18f171bc8974b64731774e62f001d78a0605;hb=bf0d9ef534d7deb2a8de5e74fd436c49bdd53a61;hp=fa682ae75025d6ee18fafbf379fab5cf79e01db1;hpb=d1f1333f481a6814bb310c934b798d9f594f0b04;p=github%2Fwallabag%2Fwallabag.git diff --git a/src/Wallabag/UserBundle/Mailer/AuthCodeMailer.php b/src/Wallabag/UserBundle/Mailer/AuthCodeMailer.php index fa682ae7..ca9d18f1 100644 --- a/src/Wallabag/UserBundle/Mailer/AuthCodeMailer.php +++ b/src/Wallabag/UserBundle/Mailer/AuthCodeMailer.php @@ -4,6 +4,7 @@ namespace Wallabag\UserBundle\Mailer; use Scheb\TwoFactorBundle\Model\Email\TwoFactorInterface; use Scheb\TwoFactorBundle\Mailer\AuthCodeMailerInterface; +use Craue\ConfigBundle\Util\Config; /** * Custom mailer for TwoFactorBundle email. @@ -46,6 +47,13 @@ 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. * @@ -53,15 +61,16 @@ class AuthCodeMailer implements AuthCodeMailerInterface * @param \Twig_Environment $twig * @param string $senderEmail * @param string $senderName - * @param string $supportUrl + * @param Config $craueConfig Craue\Config instance to get wallabag support url from database */ - public function __construct(\Swift_Mailer $mailer, \Twig_Environment $twig, $senderEmail, $senderName, $supportUrl) + public function __construct(\Swift_Mailer $mailer, \Twig_Environment $twig, $senderEmail, $senderName, Config $craueConfig) { $this->mailer = $mailer; $this->twig = $twig; $this->senderEmail = $senderEmail; $this->senderName = $senderName; - $this->supportUrl = $supportUrl; + $this->supportUrl = $craueConfig->get('wallabag_support_url'); + $this->wallabagUrl = $craueConfig->get('wallabag_url'); } /** @@ -71,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();