Commit 3d022afc authored by mglaman's avatar mglaman Committed by bojanz

Issue #2839426 by mglaman: commerce_log crashes if commerce_cart is is not enabled (#591)

parent 0ec8828c
......@@ -6,15 +6,3 @@ services:
plugin.manager.commerce_log_category:
class: Drupal\commerce_log\LogCategoryManager
arguments: ['@module_handler', '@cache.discovery']
commerce_log.cart_event_subscriber:
class: Drupal\commerce_log\EventSubscriber\CartEventSubscriber
arguments: ['@entity_type.manager']
tags:
- { name: event_subscriber }
commerce_log.order_event_subscriber:
class: Drupal\commerce_log\EventSubscriber\OrderEventSubscriber
arguments: ['@entity_type.manager']
tags:
- { name: event_subscriber }
<?php
namespace Drupal\commerce_log;
use Drupal\Core\DependencyInjection\ContainerBuilder;
use Drupal\Core\DependencyInjection\ServiceProviderBase;
use Symfony\Component\DependencyInjection\Reference;
/**
* Registers event subscribers for installed Commerce modules.
*/
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_order'])) {
$container->register('commerce_log.order_subscriber', 'Drupal\commerce_log\EventSubscriber\OrderEventSubscriber')
->addTag('event_subscriber')
->addArgument(new Reference('entity_type.manager'));
}
}
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment