By phenaproxima on
Change record status:
Published (View all published change records)
Project:
Introduced in branch:
10.1.x
Introduced in version:
10.1.0
Description:
A new validation constraint, called PluginExists, has been added to core. As the name suggests, this constraint can be used to check if the value is the ID of a plugin that exists.
The constraint requires one option, which is the service ID of the plugin manager service to query. For example, if the plugin manager is plugin.manager.block, the value is expected to be a valid block plugin ID.
The constraint also accepts an additional option, which is the fully-qualified name of an interface (or base class) that the plugin must implement (or extend). For example:
$data_definition->addConstraint('PluginExists', [
'manager' => 'plugin.manager.block',
'interface' => '\Drupal\Core\Block\BlockPluginInterface',
]);
or an example in config schema:
…
editor:
type: string
label: 'Text editor'
constraints:
PluginExists:
manager: plugin.manager.editor
…
Impacts:
Module developers