Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. ModifyServiceDefinitionsPass.php

function ModifyServiceDefinitionsPass::process

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) : 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);
        }
    }
}
RSS feed
Powered by Drupal