MessageEvent.php 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  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\Event;
  11. use Symfony\Component\Mailer\Envelope;
  12. use Symfony\Component\Mime\RawMessage;
  13. use Symfony\Contracts\EventDispatcher\Event;
  14. /**
  15. * Allows the transformation of a Message and the Envelope before the email is sent.
  16. *
  17. * @author Fabien Potencier <fabien@symfony.com>
  18. */
  19. final class MessageEvent extends Event
  20. {
  21. private $message;
  22. private $envelope;
  23. private $transport;
  24. private $queued;
  25. public function __construct(RawMessage $message, Envelope $envelope, string $transport, bool $queued = false)
  26. {
  27. $this->message = $message;
  28. $this->envelope = $envelope;
  29. $this->transport = $transport;
  30. $this->queued = $queued;
  31. }
  32. public function getMessage(): RawMessage
  33. {
  34. return $this->message;
  35. }
  36. public function setMessage(RawMessage $message): void
  37. {
  38. $this->message = $message;
  39. }
  40. public function getEnvelope(): Envelope
  41. {
  42. return $this->envelope;
  43. }
  44. public function setEnvelope(Envelope $envelope): void
  45. {
  46. $this->envelope = $envelope;
  47. }
  48. public function getTransport(): string
  49. {
  50. return $this->transport;
  51. }
  52. public function isQueued(): bool
  53. {
  54. return $this->queued;
  55. }
  56. }