public static function PluginDefinitionValidator::validateContextDefinitions in Plugin 8.2
Validates plugin context definitions.
Parameters
\Drupal\Component\Plugin\Context\ContextDefinitionInterface[] $context_definitions: The array of context definitions, keyed by context name.
Throws
\InvalidArgumentException Thrown when the class is invalid.
4 calls to PluginDefinitionValidator::validateContextDefinitions()
- ArrayPluginDefinitionDecorator::setContextDefinitions in src/
PluginDefinition/ ArrayPluginDefinitionDecorator.php - Sets the context definitions.
- ArrayPluginDefinitionDecorator::__construct in src/
PluginDefinition/ ArrayPluginDefinitionDecorator.php - Constructs a new instance.
- PluginContextDefinitionTrait::setContextDefinitions in src/
PluginDefinition/ PluginContextDefinitionTrait.php - Implements \Drupal\Component\Plugin\PluginContextDefinitionInterface::setContextDefinitions().
- PluginDefinitionValidatorTest::testValidateContextDefinitions in tests/
src/ Unit/ PluginDefinition/ PluginDefinitionValidatorTest.php - @covers ::validateContextDefinitions
File
- src/
PluginDefinition/ PluginDefinitionValidator.php, line 56
Class
- PluginDefinitionValidator
- Provides plugin definition validation.
Namespace
Drupal\plugin\PluginDefinitionCode
public static function validateContextDefinitions(array $context_definitions) {
foreach ($context_definitions as $name => $context_definition) {
if (!$context_definition instanceof ContextDefinitionInterface) {
$type = is_object($context_definition) ? get_class($context_definition) : gettype($context_definition);
throw new \InvalidArgumentException(sprintf('$context_definition[%s] (%s) does not implement required %s.', $name, $type, ContextDefinitionInterface::class));
}
}
}