Skip to content
Snippets Groups Projects
Commit f6473c09 authored by Bojan Živanović's avatar Bojan Živanović
Browse files

Issue #2874157 part II: Register the event subscriber in a service provider,...

Issue #2874157 part II: Register the event subscriber in a service provider, to avoid a commerce_tax dependency (or a crash).
parent b91bb35a
No related branches found
No related tags found
No related merge requests found
......@@ -21,11 +21,6 @@ services:
tags:
- { name: commerce_order.order_processor, priority: 200 }
commerce_shipping.customer_profile_subscriber:
class: Drupal\commerce_shipping\EventSubscriber\CustomerProfileSubscriber
tags:
- { name: event_subscriber }
commerce_shipping.referenceable_plugin_types_subscriber:
class: Drupal\commerce_shipping\EventSubscriber\ReferenceablePluginTypesSubscriber
tags:
......
<?php
namespace Drupal\commerce_shipping;
use Drupal\Core\DependencyInjection\ContainerBuilder;
use Drupal\Core\DependencyInjection\ServiceProviderBase;
/**
* Registers event subscribers for non-required modules.
*/
class CommerceShippingServiceProvider 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_tax'])) {
$container->register('commerce_shipping.customer_profile_subscriber', 'Drupal\commerce_shipping\EventSubscriber\CustomerProfileSubscriber')
->addTag('event_subscriber');
}
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment