function ContextProvidersPass::process

Same name in other branches
  1. 9 core/lib/Drupal/Core/DependencyInjection/Compiler/ContextProvidersPass.php \Drupal\Core\DependencyInjection\Compiler\ContextProvidersPass::process()
  2. 10 core/lib/Drupal/Core/DependencyInjection/Compiler/ContextProvidersPass.php \Drupal\Core\DependencyInjection\Compiler\ContextProvidersPass::process()

Passes the service IDs of all context providers to the context repository.

File

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

Class

ContextProvidersPass
Adds the context provider service IDs to the context manager.

Namespace

Drupal\Core\DependencyInjection\Compiler

Code

public function process(ContainerBuilder $container) {
    $context_providers = [];
    foreach (array_keys($container->findTaggedServiceIds('context_provider')) as $id) {
        $context_providers[] = $id;
    }
    $definition = $container->getDefinition('context.repository');
    $definition->addArgument($context_providers);
}

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