You are here

class CommerceStockTransactionSubscriber in Commerce Stock 8

Test class to test the commerce_stock transaction events.

Hierarchy

Expanded class hierarchy of CommerceStockTransactionSubscriber

1 string reference to 'CommerceStockTransactionSubscriber'
commerce_stock_local_test.services.yml in modules/local_storage/tests/modules/commerce_stock_local_test/commerce_stock_local_test.services.yml
modules/local_storage/tests/modules/commerce_stock_local_test/commerce_stock_local_test.services.yml
1 service uses CommerceStockTransactionSubscriber
commerce_stock_local_test.event_subscriber in modules/local_storage/tests/modules/commerce_stock_local_test/commerce_stock_local_test.services.yml
Drupal\commerce_stock_local_test\EventSubscriber\CommerceStockTransactionSubscriber

File

modules/local_storage/tests/modules/commerce_stock_local_test/src/EventSubscriber/CommerceStockTransactionSubscriber.php, line 15

Namespace

Drupal\commerce_stock_local_test\EventSubscriber
View source
class CommerceStockTransactionSubscriber implements EventSubscriberInterface, ContainerInjectionInterface {
  use LoggerChannelTrait;

  /**
   * Constructs a CommerceStockTransactionSubscriber object.
   */
  public function __construct() {
  }

  /**
   * @inheritDoc
   */
  public static function create(ContainerInterface $container) {
    $commerceStockTransactionSubscriber = new static();
    $commerceStockTransactionSubscriber
      ->setLoggerFactory($container
      ->get('logger.factory'));
    return $commerceStockTransactionSubscriber;
  }

  /**
   * @inheritDoc
   */
  public static function getSubscribedEvents() {
    return [
      LocalStockTransactionEvents::LOCAL_STOCK_TRANSACTION_CREATE => 'onTransactionCreate',
      LocalStockTransactionEvents::LOCAL_STOCK_TRANSACTION_INSERT => 'onTransactionInsert',
    ];
  }

  /**
   * Logging the create event.
   *
   * @param \Drupal\commerce_stock_local\Event\LocalStockTransactionEvent $event
   *   The event.
   */
  public function onTransactionCreate(LocalStockTransactionEvent $event) {
    $this
      ->getLogger('commerce_local_stock_test')
      ->debug('LOCAL_STOCK_TRANSACTION_CREATE issued', $event
      ->getStockTransaction());
  }

  /**
   * Logging the insert event.
   *
   * @param \Drupal\commerce_stock_local\Event\LocalStockTransactionEvent $event
   *   The event.
   */
  public function onTransactionInsert(LocalStockTransactionEvent $event) {
    $this
      ->getLogger('commerce_local_stock_test')
      ->debug('LOCAL_STOCK_TRANSACTION_INSERT issued', $event
      ->getStockTransaction());
  }

}

Members

Namesort descending Modifiers Type Description Overrides
CommerceStockTransactionSubscriber::create public static function @inheritDoc Overrides ContainerInjectionInterface::create
CommerceStockTransactionSubscriber::getSubscribedEvents public static function @inheritDoc
CommerceStockTransactionSubscriber::onTransactionCreate public function Logging the create event.
CommerceStockTransactionSubscriber::onTransactionInsert public function Logging the insert event.
CommerceStockTransactionSubscriber::__construct public function Constructs a CommerceStockTransactionSubscriber object.
LoggerChannelTrait::$loggerFactory protected property The logger channel factory service.
LoggerChannelTrait::getLogger protected function Gets the logger for a specific channel.
LoggerChannelTrait::setLoggerFactory public function Injects the logger channel factory.