You are here

abstract class CoreStockEventsBase in Commerce Stock 8

Core stock events base class.

Hierarchy

Expanded class hierarchy of CoreStockEventsBase

File

src/Plugin/StockEvents/CoreStockEventsBase.php, line 13

Namespace

Drupal\commerce_stock\Plugin\StockEvents
View source
abstract class CoreStockEventsBase extends PluginBase implements StockEventsInterface {

  /**
   * Helper method for building the transaction metadata.
   *
   * @param \Drupal\commerce_order\Entity\Order $order
   *   The commerce order.
   * @param \Drupal\commerce_stock\Plugin\Commerce\StockEventType\StockEventTypeInterface $stock_event_type
   *   The stock event type.
   * @param string|null $message
   *   An optional transaction message.
   * @param array $data
   *   Arbitrary data to save in transactions metadata.
   *
   * @return array
   *   The metadata.
   */
  protected function getMetadata(Order $order, StockEventTypeInterface $stock_event_type, $message = NULL, array $data = []) {
    $metadata = array_merge([
      'message' => $message ?: $stock_event_type
        ->getDefaultMessage(),
    ], $data);
    return [
      'related_oid' => $order
        ->id(),
      'related_uid' => $order
        ->getCustomerId(),
      'data' => $metadata,
    ];
  }

}

Members

Namesort descending Modifiers Type Description Overrides
CoreStockEventsBase::getMetadata protected function Helper method for building the transaction metadata.
PluginBase::$configuration protected property Configuration information passed into the plugin. 1
PluginBase::$pluginDefinition protected property The plugin implementation definition. 1
PluginBase::$pluginId protected property The plugin_id.
PluginBase::DERIVATIVE_SEPARATOR constant A string which is used to separate base plugin IDs from the derivative ID.
PluginBase::getBaseId public function Gets the base_plugin_id of the plugin instance. Overrides DerivativeInspectionInterface::getBaseId
PluginBase::getDerivativeId public function Gets the derivative_id of the plugin instance. Overrides DerivativeInspectionInterface::getDerivativeId
PluginBase::getPluginDefinition public function Gets the definition of the plugin implementation. Overrides PluginInspectionInterface::getPluginDefinition 3
PluginBase::getPluginId public function Gets the plugin_id of the plugin instance. Overrides PluginInspectionInterface::getPluginId
PluginBase::isConfigurable public function Determines if the plugin is configurable.
PluginBase::__construct public function Constructs a \Drupal\Component\Plugin\PluginBase object. 92
StockEventsInterface::configFormOptions public function Return form elements holding the configuration options. 2
StockEventsInterface::ORDER_CANCEL_EVENT constant
StockEventsInterface::ORDER_DELET_EVENT constant
StockEventsInterface::ORDER_ITEM_DELETE_EVENT constant
StockEventsInterface::ORDER_ITEM_UPDATE_EVENT constant
StockEventsInterface::ORDER_PLACE_EVENT constant
StockEventsInterface::ORDER_UPDATE_EVENT constant
StockEventsInterface::saveConfigFormOptions public function Save the configuration options. 2
StockEventsInterface::stockEvent public function A stock event with transaction details. 2