From 1a5cc4cd89943f39a15443c94a73c6979069834a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Poirier=20Th=C3=A9or=C3=AAt?= Date: Thu, 12 Dec 2024 23:21:09 -0500 Subject: [PATCH] [CronJob] Integrate DoctrineEnvelopeEntityReference custom exception --- packages/cron-job/Message/ExecuteCronJobMessage.php | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) 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;