You are here

class CartEmptyEvent in Commerce Core 8.2

Defines the cart empty event.

Hierarchy

  • class \Drupal\commerce\EventBase extends \Drupal\Component\EventDispatcher\Event

Expanded class hierarchy of CartEmptyEvent

See also

\Drupal\commerce_cart\Event\CartEvents

2 files declare their use of CartEmptyEvent
CartEventSubscriber.php in modules/promotion/src/EventSubscriber/CartEventSubscriber.php
CartManager.php in modules/cart/src/CartManager.php

File

modules/cart/src/Event/CartEmptyEvent.php, line 13

Namespace

Drupal\commerce_cart\Event
View source
class CartEmptyEvent extends EventBase {

  /**
   * The cart order.
   *
   * @var \Drupal\commerce_order\Entity\OrderInterface
   */
  protected $cart;

  /**
   * The removed order items.
   *
   * @var \Drupal\commerce_order\Entity\OrderItemInterface[]
   */
  protected $orderItems;

  /**
   * Constructs a new CartEmptyEvent.
   *
   * @param \Drupal\commerce_order\Entity\OrderInterface $cart
   *   The cart order.
   * @param \Drupal\commerce_order\Entity\OrderItemInterface[] $order_items
   *   The removed order items.
   */
  public function __construct(OrderInterface $cart, array $order_items) {
    $this->cart = $cart;
    $this->orderItems = $order_items;
  }

  /**
   * Gets the cart order.
   *
   * @return \Drupal\commerce_order\Entity\OrderInterface
   *   The cart order.
   */
  public function getCart() {
    return $this->cart;
  }

  /**
   * Gets the removed order items.
   *
   * @return \Drupal\commerce_order\Entity\OrderItemInterface[]
   *   The removed order items.
   */
  public function getOrderItems() {
    return $this->orderItems;
  }

}

Members

Namesort descending Modifiers Type Description Overrides
CartEmptyEvent::$cart protected property The cart order.
CartEmptyEvent::$orderItems protected property The removed order items.
CartEmptyEvent::getCart public function Gets the cart order.
CartEmptyEvent::getOrderItems public function Gets the removed order items.
CartEmptyEvent::__construct public function Constructs a new CartEmptyEvent.