function ContextHandler::getContextDefinitions

Same name in other branches
  1. 9 core/lib/Drupal/Core/Plugin/Context/ContextHandler.php \Drupal\Core\Plugin\Context\ContextHandler::getContextDefinitions()
  2. 8.9.x core/lib/Drupal/Core/Plugin/Context/ContextHandler.php \Drupal\Core\Plugin\Context\ContextHandler::getContextDefinitions()
  3. 11.x core/lib/Drupal/Core/Plugin/Context/ContextHandler.php \Drupal\Core\Plugin\Context\ContextHandler::getContextDefinitions()

Returns the context definitions associated with a plugin definition.

Parameters

array|\Drupal\Component\Plugin\Definition\ContextAwarePluginDefinitionInterface $plugin_definition: The plugin definition.

Return value

\Drupal\Component\Plugin\Context\ContextDefinitionInterface[]|null The context definitions, or NULL if the plugin definition does not support contexts.

1 call to ContextHandler::getContextDefinitions()
ContextHandler::filterPluginDefinitionsByContexts in core/lib/Drupal/Core/Plugin/Context/ContextHandler.php

File

core/lib/Drupal/Core/Plugin/Context/ContextHandler.php, line 49

Class

ContextHandler
Provides methods to handle sets of contexts.

Namespace

Drupal\Core\Plugin\Context

Code

protected function getContextDefinitions($plugin_definition) {
    if ($plugin_definition instanceof ContextAwarePluginDefinitionInterface) {
        return $plugin_definition->getContextDefinitions();
    }
    if (is_array($plugin_definition) && isset($plugin_definition['context_definitions'])) {
        return $plugin_definition['context_definitions'];
    }
    return NULL;
}

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