public function fillStatus(ItemInterface $item) { $this->status = self::$availableStatus[$item->getStatus()]; }
public function deleteItem(ItemInterface $item) { try { $this->entityManager->beginTransaction(); $order = $item->getOrder(); $order->removeItem($item); if ($order->getStatus() === OrderInterface::STATUS_OPEN) { $order->setCreated(new DateTime()); } $this->entityManager->persist($order); $this->entityManager->remove($item); // throw the event now, so that the ID is still set (for logging) $this->eventDispatcher->dispatch("agit.item.deleted", new ItemEvent($item)); $this->entityManager->flush(); $this->entityManager->commit(); } catch (Exception $e) { $this->entityManager->rollback(); throw $e; } }
public function discardItem(ItemInterface $item) { $order = $item->getOrder(); if (!$this->hasCartInSession($order->getId())) { throw new OrderAccessForbiddenException(Translate::t("The requested item does not belong to your cart.")); } if ($order->getStatus() !== $order::STATUS_OPEN) { throw new OrderModificationException(Translate::t("This item cannot be deleted because the order is no longer open.")); } return $this->orderService->deleteItem($item); }