You are here

public function BricksServiceProvider::alter in Bricks​ 8

Same name and namespace in other branches
  1. 2.x src/BricksServiceProvider.php \Drupal\bricks\BricksServiceProvider::alter()

Modifies existing service definitions.

Parameters

ContainerBuilder $container: The ContainerBuilder whose service definitions can be altered.

Overrides ServiceProviderBase::alter

File

src/BricksServiceProvider.php, line 18

Class

BricksServiceProvider
Service Provider for Bricks.

Namespace

Drupal\bricks

Code

public function alter(ContainerBuilder $container) {
  $modules = $container
    ->getParameter('container.modules');

  // Check for installed Replicate module.
  if (isset($modules['replicate'])) {

    // Add a Replicate field event subscriber.
    $service_definition = new Definition('Drupal\\bricks\\EventSubscriber\\ReplicateFieldSubscriber', [
      new Reference('replicate.replicator'),
    ]);
    $service_definition
      ->addTag('event_subscriber');
    $service_definition
      ->setPublic(TRUE);
    $container
      ->setDefinition('replicate.event_subscriber.bricks', $service_definition);
  }
}