MessageDataCollector.php 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  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\DataCollector;
  11. use Symfony\Component\HttpFoundation\Request;
  12. use Symfony\Component\HttpFoundation\Response;
  13. use Symfony\Component\HttpKernel\DataCollector\DataCollector;
  14. use Symfony\Component\Mailer\Event\MessageEvents;
  15. use Symfony\Component\Mailer\EventListener\MessageLoggerListener;
  16. /**
  17. * @author Fabien Potencier <fabien@symfony.com>
  18. */
  19. final class MessageDataCollector extends DataCollector
  20. {
  21. private $events;
  22. public function __construct(MessageLoggerListener $logger)
  23. {
  24. $this->events = $logger->getEvents();
  25. }
  26. /**
  27. * {@inheritdoc}
  28. */
  29. public function collect(Request $request, Response $response, \Throwable $exception = null)
  30. {
  31. $this->data['events'] = $this->events;
  32. }
  33. public function getEvents(): MessageEvents
  34. {
  35. return $this->data['events'];
  36. }
  37. /**
  38. * {@inheritdoc}
  39. */
  40. public function reset()
  41. {
  42. $this->data = [];
  43. }
  44. /**
  45. * {@inheritdoc}
  46. */
  47. public function getName()
  48. {
  49. return 'mailer';
  50. }
  51. }