diff --git a/packages/cron-job/Message/ExecuteCronJobMessage.php b/packages/cron-job/Message/ExecuteCronJobMessage.php index 0f157116..9598d9f9 100644 --- a/packages/cron-job/Message/ExecuteCronJobMessage.php +++ b/packages/cron-job/Message/ExecuteCronJobMessage.php @@ -6,14 +6,15 @@ use Draw\Component\CronJob\Entity\CronJobExecution; use Draw\Component\Messenger\AutoStamp\Message\StampingAwareInterface; +use Draw\Component\Messenger\DoctrineEnvelopeEntityReference\Exception\ObjectNotFoundException; use Draw\Component\Messenger\DoctrineEnvelopeEntityReference\Message\DoctrineReferenceAwareInterface; +use Draw\Component\Messenger\DoctrineEnvelopeEntityReference\Stamp\PropertyReferenceStamp; use Symfony\Component\Messenger\Bridge\Amqp\Transport\AmqpStamp; use Symfony\Component\Messenger\Envelope; -use Symfony\Component\Messenger\Exception\UnrecoverableMessageHandlingException; class ExecuteCronJobMessage implements DoctrineReferenceAwareInterface, StampingAwareInterface { - private ?CronJobExecution $execution; + private PropertyReferenceStamp|CronJobExecution|null $execution; public function __construct(CronJobExecution $execution) { @@ -22,8 +23,8 @@ public function __construct(CronJobExecution $execution) public function getExecution(): CronJobExecution { - if (null === $this->execution) { - throw new UnrecoverableMessageHandlingException('CronJobExecution is not set.'); + if (!$this->execution instanceof CronJobExecution) { + throw new ObjectNotFoundException(CronJobExecution::class, $this->execution); } return $this->execution;