src/QuoteBundle/Listener/Mailer/QuoteMailerListener.php line 39

Open in your IDE?
  1. <?php
  2. declare(strict_types=1);
  3. /*
  4.  * This file is part of SolidInvoice project.
  5.  *
  6.  * (c) Pierre du Plessis <open-source@solidworx.co>
  7.  *
  8.  * This source file is subject to the MIT license that is bundled
  9.  * with this source code in the file LICENSE.
  10.  */
  11. namespace SolidInvoice\QuoteBundle\Listener\Mailer;
  12. use SolidInvoice\QuoteBundle\Email\QuoteEmail;
  13. use SolidInvoice\QuoteBundle\Event\QuoteEvent;
  14. use SolidInvoice\QuoteBundle\Event\QuoteEvents;
  15. use Symfony\Component\EventDispatcher\EventSubscriberInterface;
  16. use Symfony\Component\Mailer\MailerInterface;
  17. /**
  18.  * @see \SolidInvoice\QuoteBundle\Tests\Listener\Mailer\QuoteMailerListenerTest
  19.  */
  20. class QuoteMailerListener implements EventSubscriberInterface
  21. {
  22.     public function __construct(
  23.         private readonly MailerInterface $mailer
  24.     ) {
  25.     }
  26.     public static function getSubscribedEvents(): array
  27.     {
  28.         return [
  29.             QuoteEvents::QUOTE_POST_SEND => 'onQuoteSend',
  30.         ];
  31.     }
  32.     public function onQuoteSend(QuoteEvent $event): void
  33.     {
  34.         $this->mailer->send(new QuoteEmail($event->getQuote()));
  35.     }
  36. }