class ContextProvidersPass

Same name and namespace in other branches
  1. 9 core/lib/Drupal/Core/DependencyInjection/Compiler/ContextProvidersPass.php \Drupal\Core\DependencyInjection\Compiler\ContextProvidersPass
  2. 8.9.x core/lib/Drupal/Core/DependencyInjection/Compiler/ContextProvidersPass.php \Drupal\Core\DependencyInjection\Compiler\ContextProvidersPass

Adds the context provider service IDs to the context manager.

Hierarchy

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

Expanded class hierarchy of ContextProvidersPass

Deprecated

in drupal:10.2.0 and is removed from drupal:11.0.0. The context.repository service uses the service_id_collector pattern instead so this is no longer needed.

See also

https://www.drupal.org/node/3416153

File

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

Namespace

Drupal\Core\DependencyInjection\Compiler
View source
class ContextProvidersPass implements CompilerPassInterface {
    
    /**
     * {@inheritdoc}
     *
     * Passes the service IDs of all context providers to the context repository.
     */
    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);
    }

}

Members

Title Sort descending Modifiers Object type Summary
ContextProvidersPass::process public function Passes the service IDs of all context providers to the context repository.

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