You are here

class CommerceLogServiceProvider in Commerce Core 8.2

Registers event subscribers for installed Commerce modules.

Hierarchy

Expanded class hierarchy of CommerceLogServiceProvider

File

modules/log/src/CommerceLogServiceProvider.php, line 12

Namespace

Drupal\commerce_log
View source
class CommerceLogServiceProvider extends ServiceProviderBase {

  /**
   * {@inheritdoc}
   */
  public function register(ContainerBuilder $container) {

    // We cannot use the module handler as the container is not yet compiled.
    // @see \Drupal\Core\DrupalKernel::compileContainer()
    $modules = $container
      ->getParameter('container.modules');
    if (isset($modules['commerce_cart'])) {
      $container
        ->register('commerce_log.cart_subscriber', 'Drupal\\commerce_log\\EventSubscriber\\CartEventSubscriber')
        ->addTag('event_subscriber')
        ->addArgument(new Reference('entity_type.manager'));
    }
    if (isset($modules['commerce_checkout'])) {
      $container
        ->register('commerce_log.checkout_subscriber', 'Drupal\\commerce_log\\EventSubscriber\\CheckoutEventSubscriber')
        ->addTag('event_subscriber')
        ->addArgument(new Reference('entity_type.manager'));
    }
    if (isset($modules['commerce_order'])) {
      $container
        ->register('commerce_log.order_subscriber', 'Drupal\\commerce_log\\EventSubscriber\\OrderEventSubscriber')
        ->addTag('event_subscriber')
        ->addArgument(new Reference('entity_type.manager'));
      $container
        ->register('commerce_log.order_mail_subscriber', 'Drupal\\commerce_log\\EventSubscriber\\OrderMailEventSubscriber')
        ->addTag('event_subscriber')
        ->addArgument(new Reference('entity_type.manager'))
        ->addArgument(new Reference('plugin.manager.commerce_log_template'));
    }
  }

}

Members

Namesort descending Modifiers Type Description Overrides
CommerceLogServiceProvider::register public function Registers services to the container. Overrides ServiceProviderBase::register
ServiceProviderBase::alter public function Modifies existing service definitions. Overrides ServiceModifierInterface::alter 5