You are here

public function ContextProviderInterface::getAvailableContexts in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/lib/Drupal/Core/Plugin/Context/ContextProviderInterface.php \Drupal\Core\Plugin\Context\ContextProviderInterface::getAvailableContexts()

Gets all available contexts for the purposes of configuration.

When a context aware plugin is being configured, the configuration UI must know which named contexts are potentially available, but does not care about the value, since the value can be different for each request, and might not be available at all during the configuration UI's request.

For example:

// During configuration, there is no specific node to pass as context.
// However, inform the system that a context named 'node' is
// available, and provide its definition, so that context aware plugins
// can be configured to use it. When the plugin, for example a block,
// needs to evaluate the context, the value of this context will be
// supplied by getRuntimeContexts().
$context = new Context(new ContextDefinition('entity:node'));
return [
  'node' => $context,
];

Return value

\Drupal\Core\Plugin\Context\ContextInterface[] All available contexts keyed by the unqualified context ID.

See also

\Drupal\Core\Plugin\Context\ContextProviderInterface::getRuntimeContext()

4 methods override ContextProviderInterface::getAvailableContexts()
CurrentLanguageContext::getAvailableContexts in core/lib/Drupal/Core/Language/ContextProvider/CurrentLanguageContext.php
Gets all available contexts for the purposes of configuration.
CurrentUserContext::getAvailableContexts in core/modules/user/src/ContextProvider/CurrentUserContext.php
Gets all available contexts for the purposes of configuration.
MultipleStaticContext::getAvailableContexts in core/modules/block/tests/modules/block_test/src/ContextProvider/MultipleStaticContext.php
Gets all available contexts for the purposes of configuration.
NodeRouteContext::getAvailableContexts in core/modules/node/src/ContextProvider/NodeRouteContext.php
Gets all available contexts for the purposes of configuration.

File

core/lib/Drupal/Core/Plugin/Context/ContextProviderInterface.php, line 79
Contains \Drupal\Core\Plugin\Context\ContextProviderInterface.

Class

ContextProviderInterface
Defines an interface for providing plugin contexts.

Namespace

Drupal\Core\Plugin\Context

Code

public function getAvailableContexts();