src/EventSubscriber/OrderSubscriber.php line 36
<?phpnamespace App\EventSubscriber;use App\Entity\Order;use App\Event\OrderCreatedEvent;use App\Service\InventoryService;use App\Service\OrderService;use Exception;use Symfony\Component\EventDispatcher\EventSubscriberInterface;class OrderSubscriber implements EventSubscriberInterface{/*** @param InventoryService $inventoryService* @param OrderService $orderService*/public function __construct(private InventoryService $inventoryService,private OrderService $orderService) {}/*** @return array*/public static function getSubscribedEvents(): array{return [OrderCreatedEvent::class => 'orderCreatedAction',];}/*** @throws Exception*/public function orderCreatedAction(OrderCreatedEvent $event){$order = $event->getOrder();if ($order->isInvalidDeliveryDataStatus() || $order->isDuplicateStatus()) {return;}if ($this->inventoryService->isProductsReservationCouldBeDone($order)) {$this->inventoryService->orderProductsReservation($order);} else {$this->orderService->changeStatus($order, Order::STATUS_NOT_ENOUGH_RESERVATION_QUANTITY);}}}