class CartEntityAddEvent in Commerce Core 8.2
Defines the cart entity add event.
Hierarchy
- class \Drupal\commerce\EventBase extends \Drupal\Component\EventDispatcher\Event
- class \Drupal\commerce_cart\Event\CartEntityAddEvent
Expanded class hierarchy of CartEntityAddEvent
See also
\Drupal\commerce_cart\Event\CartEvents
3 files declare their use of CartEntityAddEvent
- CartEventSubscriber.php in modules/
log/ src/ EventSubscriber/ CartEventSubscriber.php - CartEventSubscriber.php in modules/
cart/ src/ EventSubscriber/ CartEventSubscriber.php - CartManager.php in modules/
cart/ src/ CartManager.php
File
- modules/
cart/ src/ Event/ CartEntityAddEvent.php, line 15
Namespace
Drupal\commerce_cart\EventView source
class CartEntityAddEvent extends EventBase {
/**
* The cart order.
*
* @var \Drupal\commerce_order\Entity\OrderInterface
*/
protected $cart;
/**
* The added entity.
*
* @var \Drupal\commerce\PurchasableEntityInterface
*/
protected $entity;
/**
* The quantity.
*
* @var float
*/
protected $quantity;
/**
* The destination order item.
*
* @var \Drupal\commerce_order\Entity\OrderItemInterface
*/
protected $orderItem;
/**
* Constructs a new CartOrderItemEvent.
*
* @param \Drupal\commerce_order\Entity\OrderInterface $cart
* The cart order.
* @param \Drupal\commerce\PurchasableEntityInterface $entity
* The added entity.
* @param float $quantity
* The quantity.
* @param \Drupal\commerce_order\Entity\OrderItemInterface $order_item
* The destination order item.
*/
public function __construct(OrderInterface $cart, PurchasableEntityInterface $entity, $quantity, OrderItemInterface $order_item) {
$this->cart = $cart;
$this->entity = $entity;
$this->quantity = $quantity;
$this->orderItem = $order_item;
}
/**
* Gets the cart order.
*
* @return \Drupal\commerce_order\Entity\OrderInterface
* The cart order.
*/
public function getCart() {
return $this->cart;
}
/**
* Gets the added entity.
*
* @return \Drupal\commerce\PurchasableEntityInterface
* The added entity.
*/
public function getEntity() {
return $this->entity;
}
/**
* Gets the quantity.
*
* @return float
* The quantity.
*/
public function getQuantity() {
return $this->quantity;
}
/**
* Gets the destination order item.
*
* @return \Drupal\commerce_order\Entity\OrderItemInterface
* The destination order item.
*/
public function getOrderItem() {
return $this->orderItem;
}
}
Members
Name![]() |
Modifiers | Type | Description | Overrides |
---|---|---|---|---|
CartEntityAddEvent:: |
protected | property | The cart order. | |
CartEntityAddEvent:: |
protected | property | The added entity. | |
CartEntityAddEvent:: |
protected | property | The destination order item. | |
CartEntityAddEvent:: |
protected | property | The quantity. | |
CartEntityAddEvent:: |
public | function | Gets the cart order. | |
CartEntityAddEvent:: |
public | function | Gets the added entity. | |
CartEntityAddEvent:: |
public | function | Gets the destination order item. | |
CartEntityAddEvent:: |
public | function | Gets the quantity. | |
CartEntityAddEvent:: |
public | function | Constructs a new CartOrderItemEvent. |