You are here

public function ContextAwarePluginTrait::getContextDefinitions in Drupal 10

Same name and namespace in other branches
  1. 9 core/lib/Drupal/Core/Plugin/ContextAwarePluginTrait.php \Drupal\Core\Plugin\ContextAwarePluginTrait::getContextDefinitions()

Return value

\Drupal\Core\Plugin\Context\ContextDefinitionInterface[]

File

core/lib/Drupal/Core/Plugin/ContextAwarePluginTrait.php, line 126

Class

ContextAwarePluginTrait
Provides a trait to add context-aware functionality to plugins.

Namespace

Drupal\Core\Plugin

Code

public function getContextDefinitions() {
  $definition = $this
    ->getPluginDefinition();
  if ($definition instanceof ContextAwarePluginDefinitionInterface) {
    return $definition
      ->getContextDefinitions();
  }
  return !empty($definition['context_definitions']) ? $definition['context_definitions'] : [];
}