/**
  * @param Basket $basket
  * @return BasketItemUpdateAction
  */
 public function setBasketItem(Basket $basket)
 {
     if (!$basket->isOwnedBy($this->user)) {
         throw new NotFoundHttpException("Basket item does not exists");
     }
     parent::setObject($basket);
     return $this;
 }
Example #2
0
 /**
  * Creates new entity
  *
  * @return mixed
  */
 public function execute()
 {
     if ($this->object->isActive()) {
         throw new \LogicException('Order is active');
     }
     if ($this->object->hasItems()) {
         throw new \LogicException('Order has items');
     }
     $message = 'Deleting order: ' . $this->object->getExecutionAt()->format('Y-m-d') . '.';
     foreach ($this->object->getItems() as $item) {
         $message .= ' Item: User.id=' . $item->getOwner()->getId() . ' Product.id=' . $item->getProduct()->getId() . ' quantity=' . $item->getQuantity() . '.';
     }
     $this->logger->info($message);
     parent::execute();
     $this->postRemove($this->object);
 }
 /**
  * @param Product $product
  * @return ProductRemoveAction
  */
 public function setProduct(Product $product)
 {
     parent::setObject($product);
     return $this;
 }
 /**
  * @param Supplier $supplier
  * @return SupplierRemoveAction
  */
 public function setSupplier(Supplier $supplier)
 {
     parent::setObject($supplier);
     return $this;
 }