/** * {@inheritdoc} */ public function release(\DateTime $expiresAt) { $orders = $this->repository->findExpired($expiresAt); foreach ($orders as $order) { $this->factory->get($order, OrderTransitions::GRAPH)->apply(OrderTransitions::SYLIUS_RELEASE, true); } $this->manager->flush(); }
/** * {@inheritdoc} */ public function purge() { $orders = $this->repository->findExpired($this->expiresAt); foreach ($orders as $order) { // Check if order has any on-hold inventory units. $hasOnHoldInventoryUnits = $order->getInventoryUnits()->exists(function ($key, InventoryUnitInterface $inventoryUnit) { return InventoryUnitInterface::STATE_ONHOLD === $inventoryUnit->getInventoryState(); }); if (!$hasOnHoldInventoryUnits) { $this->purgeOrder($order); } } $this->manager->flush(); }