interface ContextRepositoryInterface

Same name and namespace in other branches
  1. 9 core/lib/Drupal/Core/Plugin/Context/ContextRepositoryInterface.php \Drupal\Core\Plugin\Context\ContextRepositoryInterface
  2. 8.9.x core/lib/Drupal/Core/Plugin/Context/ContextRepositoryInterface.php \Drupal\Core\Plugin\Context\ContextRepositoryInterface
  3. 10 core/lib/Drupal/Core/Plugin/Context/ContextRepositoryInterface.php \Drupal\Core\Plugin\Context\ContextRepositoryInterface

Offers a global context repository.

Provides a list of all available contexts, which is mostly useful for configuration on forms, as well as a method to get the concrete contexts with their values, given a list of fully qualified context IDs.

Hierarchy

Expanded class hierarchy of ContextRepositoryInterface

All classes that implement ContextRepositoryInterface

See also

\Drupal\Core\Plugin\Context\ContextProviderInterface

6 files declare their use of ContextRepositoryInterface
BlockAccessControlHandler.php in core/modules/block/src/BlockAccessControlHandler.php
BlockForm.php in core/modules/block/src/BlockForm.php
ConfigureBlockFormBase.php in core/modules/layout_builder/src/Form/ConfigureBlockFormBase.php
EntityRepository.php in core/lib/Drupal/Core/Entity/EntityRepository.php
EntityRepositoryTest.php in core/tests/Drupal/Tests/Core/Entity/EntityRepositoryTest.php

... See full list

File

core/lib/Drupal/Core/Plugin/Context/ContextRepositoryInterface.php, line 14

Namespace

Drupal\Core\Plugin\Context
View source
interface ContextRepositoryInterface {
    
    /**
     * Gets runtime context values for the given context IDs.
     *
     * Given that context providers might not return contexts for the given
     * context IDs, it is also not guaranteed that the context repository returns
     * contexts for all specified IDs.
     *
     * @param string[] $context_ids
     *   Fully qualified context IDs, which looks like
     *   @{service_id}:{unqualified_context_id}, so for example
     *   node.node_route_context:node.
     *
     * @return \Drupal\Core\Plugin\Context\ContextInterface[]
     *   The determined contexts, keyed by the fully qualified context ID.
     */
    public function getRuntimeContexts(array $context_ids);
    
    /**
     * Gets all available contexts for the purposes of configuration.
     *
     * @return \Drupal\Core\Plugin\Context\ContextInterface[]
     *   All available contexts.
     */
    public function getAvailableContexts();

}

Members

Title Sort descending Modifiers Object type Summary Overrides
ContextRepositoryInterface::getAvailableContexts public function Gets all available contexts for the purposes of configuration. 1
ContextRepositoryInterface::getRuntimeContexts public function Gets runtime context values for the given context IDs. 1

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