You are here

public function ArrayPluginDefinitionDecorator::getContextDefinition in Plugin 8.2

Gets a specific context definition.

Parameters

string $name: The name of the context in the plugin definition.

Return value

\Drupal\Component\Plugin\Context\ContextDefinitionInterface

Throws

\InvalidArgumentException If the requested context does not exist.

Overrides PluginContextDefinitionInterface::getContextDefinition

See also

self::hasContextDefinition()

File

src/PluginDefinition/ArrayPluginDefinitionDecorator.php, line 249

Class

ArrayPluginDefinitionDecorator
Provides a plugin definition based on an array.

Namespace

Drupal\plugin\PluginDefinition

Code

public function getContextDefinition($name) {
  if (!$this
    ->hasContextDefinition($name)) {
    throw new \InvalidArgumentException(sprintf('Context %s does not exist.', $name));
  }
  return $this->arrayDefinition['context'][$name];
}