AbstractWorkerMessageEvent.php 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  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\Messenger\Event;
  11. use Symfony\Component\Messenger\Envelope;
  12. use Symfony\Component\Messenger\Stamp\StampInterface;
  13. abstract class AbstractWorkerMessageEvent
  14. {
  15. private $envelope;
  16. private $receiverName;
  17. public function __construct(Envelope $envelope, string $receiverName)
  18. {
  19. $this->envelope = $envelope;
  20. $this->receiverName = $receiverName;
  21. }
  22. public function getEnvelope(): Envelope
  23. {
  24. return $this->envelope;
  25. }
  26. /**
  27. * Returns a unique identifier for transport receiver this message was received from.
  28. */
  29. public function getReceiverName(): string
  30. {
  31. return $this->receiverName;
  32. }
  33. public function addStamps(StampInterface ...$stamps): void
  34. {
  35. $this->envelope = $this->envelope->with(...$stamps);
  36. }
  37. }