Sonata\Component\Basket\BasketElementInterface::getDelete PHP Method

getDelete() public method

public getDelete ( ) : boolean
return boolean
    public function getDelete();

Usage Example

 /**
  * {@inheritdoc}
  */
 public function validateFormBasketElement(ErrorElement $errorElement, BasketElementInterface $basketElement, BasketInterface $basket)
 {
     // the item is flagged as deleted, no need to validate the item
     if ($basketElement->getDelete() || 0 === $basketElement->getQuantity()) {
         return;
     }
     // refresh the product from the database
     $product = $basketElement->getProduct();
     // check if the product is still in database
     if (!$product) {
         $errorElement->addViolation('product_not_available');
         return;
     }
     // check if the product is still enabled
     if (!$basketElement->getProduct()->getEnabled()) {
         $errorElement->addViolation('product_not_enabled');
         return;
     }
     // check if the quantity is numeric
     if (!is_numeric($basketElement->getQuantity())) {
         $errorElement->with('quantity')->addViolation('product_quantity_not_numeric')->end();
         return;
     }
     $errorElement->with('quantity')->assertRange(array('min' => 1, 'max' => $this->getStockAvailable($basketElement->getProduct()), 'minMessage' => 'basket_quantity_limit_min', 'maxMessage' => 'basket_quantity_limit_max'))->end();
 }