diff --git a/app/config/config.yml b/app/config/config.yml index 5e53f992f..473246438 100644 --- a/app/config/config.yml +++ b/app/config/config.yml @@ -197,7 +197,7 @@ fos_user: address: "%from_email%" sender_name: wallabag service: - mailer: Wallabag\Mailer\UserMailer + mailer: fos_user.mailer.twig_symfony fos_oauth_server: db_driver: orm diff --git a/app/config/services.yml b/app/config/services.yml index 704c24295..3cca8b30f 100644 --- a/app/config/services.yml +++ b/app/config/services.yml @@ -260,16 +260,6 @@ services: $defaultSettings: '%wallabag.default_internal_settings%' $defaultIgnoreOriginInstanceRules: '%wallabag.default_ignore_origin_instance_rules%' - Wallabag\Mailer\UserMailer: - arguments: - $parameters: - template: - confirmation: '%fos_user.registration.confirmation.template%' - resetting: '%fos_user.resetting.email.template%' - from_email: - confirmation: '%fos_user.registration.confirmation.from_email%' - resetting: '%fos_user.resetting.email.from_email%' - Wallabag\Event\Listener\CreateConfigListener: arguments: $itemsOnPage: "%wallabag.items_on_page%" diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index 8b8938125..e3bfe3f0a 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -60,11 +60,6 @@ parameters: count: 2 path: src/Mailer/AuthCodeMailer.php - - - message: "#^PHPDoc type Symfony\\\\Component\\\\Mailer\\\\MailerInterface of property Wallabag\\\\Mailer\\\\UserMailer\\:\\:\\$mailer is not covariant with PHPDoc type Swift_Mailer of overridden property FOS\\\\UserBundle\\\\Mailer\\\\TwigSwiftMailer\\:\\:\\$mailer\\.$#" - count: 1 - path: src/Mailer/UserMailer.php - - message: "#^Call to an undefined method DOMNode\\:\\:getAttribute\\(\\)\\.$#" count: 1 diff --git a/src/Mailer/UserMailer.php b/src/Mailer/UserMailer.php deleted file mode 100644 index fa108c3e4..000000000 --- a/src/Mailer/UserMailer.php +++ /dev/null @@ -1,78 +0,0 @@ -|string, resetting: array|string}} - */ - protected $parameters; - - public function __construct(MailerInterface $mailer, UrlGeneratorInterface $router, Environment $twig, array $parameters) - { - $this->mailer = $mailer; - $this->router = $router; - $this->twig = $twig; - $this->parameters = $parameters; - } - - /** - * @param string $templateName - * @param array $context - * @param array $fromEmail - * @param string $toEmail - */ - protected function sendMessage($templateName, $context, $fromEmail, $toEmail) - { - $template = $this->twig->load($templateName); - $subject = $template->renderBlock('subject', $context); - $textBody = $template->renderBlock('body_text', $context); - - $htmlBody = ''; - - if ($template->hasBlock('body_html', $context)) { - $htmlBody = $template->renderBlock('body_html', $context); - } - - $email = (new Email()) - ->from(new Address(key($fromEmail), current($fromEmail))) - ->to($toEmail) - ->subject($subject); - - if (!empty($htmlBody)) { - $email - ->text($textBody) - ->html($htmlBody); - } else { - $email->text($textBody); - } - - $this->mailer->send($email); - } -}