W3cubDocs

/Drupal 8

public function ModifyServiceDefinitionsPass::process

public ModifyServiceDefinitionsPass::process(ContainerBuilder $container)

You can modify the container here before it is dumped to PHP code.

Parameters

ContainerBuilder $container:

Overrides CompilerPassInterface::process

File

core/lib/Drupal/Core/DependencyInjection/Compiler/ModifyServiceDefinitionsPass.php, line 18

Class

ModifyServiceDefinitionsPass
Passes the container to the alter() method of all service providers.

Namespace

Drupal\Core\DependencyInjection\Compiler

Code

public function process(ContainerBuilder $container) {
  if (!$container->has('kernel')) {
    return;
  }

  $kernel = $container->get('kernel');
  if (!($kernel instanceof DrupalKernelInterface)) {
    return;
  }
  $providers = $kernel->getServiceProviders('app');
  foreach ($providers as $provider) {
    if ($provider instanceof ServiceModifierInterface) {
      $provider->alter($container);
    }
  }
  $providers = $kernel->getServiceProviders('site');
  foreach ($providers as $provider) {
    if ($provider instanceof ServiceModifierInterface) {
      $provider->alter($container);
    }
  }
}

© 2001–2016 by the original authors
Licensed under the GNU General Public License, version 2 and later.
Drupal is a registered trademark of Dries Buytaert.
https://api.drupal.org/api/drupal/core!lib!Drupal!Core!DependencyInjection!Compiler!ModifyServiceDefinitionsPass.php/function/ModifyServiceDefinitionsPass::process/8.1.x