class ModifyServiceDefinitionsPass

Same name in other branches
  1. 9 core/lib/Drupal/Core/DependencyInjection/Compiler/ModifyServiceDefinitionsPass.php \Drupal\Core\DependencyInjection\Compiler\ModifyServiceDefinitionsPass
  2. 8.9.x core/lib/Drupal/Core/DependencyInjection/Compiler/ModifyServiceDefinitionsPass.php \Drupal\Core\DependencyInjection\Compiler\ModifyServiceDefinitionsPass
  3. 10 core/lib/Drupal/Core/DependencyInjection/Compiler/ModifyServiceDefinitionsPass.php \Drupal\Core\DependencyInjection\Compiler\ModifyServiceDefinitionsPass

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

Hierarchy

  • class \Drupal\Core\DependencyInjection\Compiler\ModifyServiceDefinitionsPass implements \Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface

Expanded class hierarchy of ModifyServiceDefinitionsPass

1 file declares its use of ModifyServiceDefinitionsPass
CoreServiceProvider.php in core/lib/Drupal/Core/CoreServiceProvider.php

File

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

Namespace

Drupal\Core\DependencyInjection\Compiler
View source
class ModifyServiceDefinitionsPass implements CompilerPassInterface {
    
    /**
     * {@inheritdoc}
     */
    public function process(ContainerBuilder $container) : void {
        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);
            }
        }
    }

}

Members

Title Sort descending Modifiers Object type Summary
ModifyServiceDefinitionsPass::process public function

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.