class LocalStockTransactionEvent in Commerce Stock 8
Defines the stock location event.
Hierarchy
- class \Drupal\commerce_stock_local\Event\LocalStockTransactionEvent extends \Symfony\Component\EventDispatcher\Event
Expanded class hierarchy of LocalStockTransactionEvent
3 files declare their use of LocalStockTransactionEvent
- CommerceLocalStockTransactionSubscriber.php in modules/local_storage/ src/ EventSubscriber/ CommerceLocalStockTransactionSubscriber.php 
- CommerceStockTransactionSubscriber.php in modules/local_storage/ tests/ modules/ commerce_stock_local_test/ src/ EventSubscriber/ CommerceStockTransactionSubscriber.php 
- LocalStockUpdater.php in modules/local_storage/ src/ LocalStockUpdater.php 
File
- modules/local_storage/ src/ Event/ LocalStockTransactionEvent.php, line 11 
Namespace
Drupal\commerce_stock_local\EventView source
class LocalStockTransactionEvent extends Event {
  /**
   * The stock transaction.
   *
   * @var array
   *   Assoziative array containing all the values of the transaction.
   *   This is essentially a map of the database columns.
   *
   * @see \Drupal\commerce_stock_local\LocalStockUpdater::createTransaction()
   */
  protected $stockTransaction;
  /**
   * The entity type manager.
   *
   * @var \Drupal\Core\Entity\EntityTypeManagerInterface
   */
  protected $entityTypeManager;
  /**
   * Constructs a new stock transaction event.
   *
   * @param \Drupal\Core\Entity\EntityTypeManagerInterface $entity_type_manager
   *   The entity type manager.
   * @param array $stock_transaction
   *   The local stock location.
   */
  public function __construct(EntityTypeManagerInterface $entity_type_manager, array $stock_transaction) {
    $this->entityTypeManager = $entity_type_manager;
    $this->stockTransaction = $stock_transaction;
  }
  /**
   * Get the stock_location for this transaction.
   *
   * @return \Drupal\commerce_stock\StockLocationInterface
   *   The stock location.
   */
  public function getTransactionLocation() {
    $locationId = $this->stockTransaction['location_id'];
    return $this->entityTypeManager
      ->getStorage('commerce_stock_location')
      ->load($locationId);
  }
  /**
   * Get the purchasable entity.
   *
   * @return \Drupal\commerce\PurchasableEntityInterface
   *   The purchasable entity.
   */
  public function getEntity() {
    $entityId = $this->stockTransaction['entity_id'];
    $entityType = $this->stockTransaction['entity_type'];
    return $this->entityTypeManager
      ->getStorage($entityType)
      ->load($entityId);
  }
  /**
   * Get the quantity.
   *
   * @return int
   *   The quantity value.
   */
  public function getQuantity() {
    return $this->stockTransaction['qty'];
  }
  /**
   * Get the stock transaction.
   *
   * @return object
   *   The local stock transaction.
   */
  public function getStockTransaction() {
    return $this->stockTransaction;
  }
}Members
| Name   | Modifiers | Type | Description | Overrides | 
|---|---|---|---|---|
| LocalStockTransactionEvent:: | protected | property | The entity type manager. | |
| LocalStockTransactionEvent:: | protected | property | The stock transaction. | |
| LocalStockTransactionEvent:: | public | function | Get the purchasable entity. | |
| LocalStockTransactionEvent:: | public | function | Get the quantity. | |
| LocalStockTransactionEvent:: | public | function | Get the stock transaction. | |
| LocalStockTransactionEvent:: | public | function | Get the stock_location for this transaction. | |
| LocalStockTransactionEvent:: | public | function | Constructs a new stock transaction event. | 
