vendor/symfony/notifier/EventListener/NotificationLoggerListener.php line 39

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\Notifier\EventListener;
  11. use Symfony\Component\EventDispatcher\EventSubscriberInterface;
  12. use Symfony\Component\Notifier\Event\MessageEvent;
  13. use Symfony\Component\Notifier\Event\NotificationEvents;
  14. use Symfony\Contracts\Service\ResetInterface;
  15. /**
  16. * @author Fabien Potencier <fabien@symfony.com>
  17. */
  18. class NotificationLoggerListener implements EventSubscriberInterface, ResetInterface
  19. {
  20. private $events;
  21. public function __construct()
  22. {
  23. $this->events = new NotificationEvents();
  24. }
  25. /**
  26. * {@inheritdoc}
  27. */
  28. public function reset()
  29. {
  30. $this->events = new NotificationEvents();
  31. }
  32. public function onNotification(MessageEvent $event): void
  33. {
  34. $this->events->add($event);
  35. }
  36. public function getEvents(): NotificationEvents
  37. {
  38. return $this->events;
  39. }
  40. public static function getSubscribedEvents()
  41. {
  42. return [
  43. MessageEvent::class => ['onNotification', -255],
  44. ];
  45. }
  46. }