function PluginExistsConstraint::create
Same name in other branches
- 10 core/lib/Drupal/Core/Plugin/Plugin/Validation/Constraint/PluginExistsConstraint.php \Drupal\Core\Plugin\Plugin\Validation\Constraint\PluginExistsConstraint::create()
Overrides ContainerFactoryPluginInterface::create
2 calls to PluginExistsConstraint::create()
- PluginExistsConstraintTest::testMissingOption in core/
tests/ Drupal/ Tests/ Core/ Plugin/ PluginExistsConstraintTest.php - Tests missing option.
- PluginExistsConstraintTest::testOption in core/
tests/ Drupal/ Tests/ Core/ Plugin/ PluginExistsConstraintTest.php - Tests with different option keys.
File
-
core/
lib/ Drupal/ Core/ Plugin/ Plugin/ Validation/ Constraint/ PluginExistsConstraint.php, line 79
Class
- PluginExistsConstraint
- Checks if a plugin exists and optionally implements a particular interface.
Namespace
Drupal\Core\Plugin\Plugin\Validation\ConstraintCode
public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) {
$plugin_manager_id = $configuration['manager'] ?? $configuration['value'] ?? NULL;
if ($plugin_manager_id === NULL) {
throw new MissingOptionsException(sprintf('The option "manager" must be set for constraint "%s".', static::class), [
'manager',
]);
}
return new static($container->get($plugin_manager_id), $configuration);
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.