vendor/symfony/mailer/EventListener/MessageLoggerListener.php line 41

Open in your IDE?
  1. <?php
  2. /*
  3. * This file is part of the Symfony package.
  4. *
  5. * (c) Fabien Potencier <fabien@symfony.com>
  6. *
  7. * For the full copyright and license information, please view the LICENSE
  8. * file that was distributed with this source code.
  9. */
  10. namespace Symfony\Component\Mailer\EventListener;
  11. use Symfony\Component\EventDispatcher\EventSubscriberInterface;
  12. use Symfony\Component\Mailer\Event\MessageEvent;
  13. use Symfony\Component\Mailer\Event\MessageEvents;
  14. use Symfony\Contracts\Service\ResetInterface;
  15. /**
  16. * Logs Messages.
  17. *
  18. * @author Fabien Potencier <fabien@symfony.com>
  19. */
  20. class MessageLoggerListener implements EventSubscriberInterface, ResetInterface
  21. {
  22. private $events;
  23. public function __construct()
  24. {
  25. $this->events = new MessageEvents();
  26. }
  27. /**
  28. * {@inheritdoc}
  29. */
  30. public function reset()
  31. {
  32. $this->events = new MessageEvents();
  33. }
  34. public function onMessage(MessageEvent $event): void
  35. {
  36. $this->events->add($event);
  37. }
  38. public function getEvents(): MessageEvents
  39. {
  40. return $this->events;
  41. }
  42. public static function getSubscribedEvents()
  43. {
  44. return [
  45. MessageEvent::class => ['onMessage', -255],
  46. ];
  47. }
  48. }