Skip to content

Commit 2581f0d

Browse files
committed
Add log in event dispatcher
1 parent 27057aa commit 2581f0d

1 file changed

Lines changed: 8 additions & 0 deletions

File tree

src/Dispatcher/OrderMessageDispatcher.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,18 +12,26 @@
1212
namespace BitBag\SyliusUserComPlugin\Dispatcher;
1313

1414
use BitBag\SyliusUserComPlugin\Message\OrderSynchronization;
15+
use Psr\Log\LoggerInterface;
1516
use Sylius\Component\Core\Model\OrderInterface;
1617
use Symfony\Component\Messenger\MessageBusInterface;
1718

1819
final class OrderMessageDispatcher implements OrderMessageDispatcherInterface
1920
{
2021
public function __construct(
2122
private readonly MessageBusInterface $messageBus,
23+
private readonly LoggerInterface $logger
2224
) {
2325
}
2426

2527
public function dispatch(OrderInterface $order): void
2628
{
29+
if (null === $order->getId()) {
30+
$this->logger->error('Order ID cannot be null');
31+
32+
return;
33+
}
34+
2735
$this->messageBus->dispatch(new OrderSynchronization($order->getId()));
2836
}
2937
}

0 commit comments

Comments
 (0)