function SourceEditingRedundantTagsConstraintValidator::pluginsSupplyingTagsMessage
Same name and namespace in other branches
- 10 core/modules/ckeditor5/src/Plugin/Validation/Constraint/SourceEditingRedundantTagsConstraintValidator.php \Drupal\ckeditor5\Plugin\Validation\Constraint\SourceEditingRedundantTagsConstraintValidator::pluginsSupplyingTagsMessage()
- 11.x core/modules/ckeditor5/src/Plugin/Validation/Constraint/SourceEditingRedundantTagsConstraintValidator.php \Drupal\ckeditor5\Plugin\Validation\Constraint\SourceEditingRedundantTagsConstraintValidator::pluginsSupplyingTagsMessage()
Creates a message listing plugins and the overlapping tags they provide.
Parameters
\Drupal\ckeditor5\HTMLRestrictions $overlap: An array of overlapping tags.
\Drupal\ckeditor5\Plugin\CKEditor5PluginDefinition[] $plugin_definitions: An array of plugin definitions where overlap was found.
\Drupal\ckeditor5\HTMLRestrictions $enabled_plugin_restrictions: The set of HTML restrictions for all already enabled CKEditor 5 plugins.
Return value
string A list of plugins that provide the overlapping tags.
1 call to SourceEditingRedundantTagsConstraintValidator::pluginsSupplyingTagsMessage()
- SourceEditingRedundantTagsConstraintValidator::validate in core/
modules/ ckeditor5/ src/ Plugin/ Validation/ Constraint/ SourceEditingRedundantTagsConstraintValidator.php
File
-
core/
modules/ ckeditor5/ src/ Plugin/ Validation/ Constraint/ SourceEditingRedundantTagsConstraintValidator.php, line 177
Class
- SourceEditingRedundantTagsConstraintValidator
- Ensures tags already available via plugin are not be added to Source Editing.
Namespace
Drupal\ckeditor5\Plugin\Validation\ConstraintCode
private function pluginsSupplyingTagsMessage(HTMLRestrictions $overlap, array $plugin_definitions, HTMLRestrictions $enabled_plugin_restrictions) : string {
$message_array = [];
$message_string = '';
foreach ($plugin_definitions as $definition) {
if ($definition->hasElements()) {
$plugin_capabilities = HTMLRestrictions::fromString(implode(' ', $definition->getElements()));
// If this plugin supports wildcards, resolve them.
if (!$plugin_capabilities->getWildcardSubset()
->allowsNothing()) {
$plugin_capabilities = $plugin_capabilities->merge($enabled_plugin_restrictions)
->diff($enabled_plugin_restrictions);
}
// Skip plugins that provide a subset, only mention the plugin that
// actually provides the overlap.
// For example: avoid listing the image alignment/captioning plugins
// when matching `<img src>`; only lists the main image plugin.
if (!$overlap->diff($plugin_capabilities)
->allowsNothing()) {
continue;
}
foreach ($plugin_capabilities->intersect($overlap)
->toCKEditor5ElementsArray() as $element) {
$message_array[(string) $definition->label()][] = $element;
}
}
}
foreach ($message_array as $plugin_label => $tag_list) {
$tags_string = implode(', ', $tag_list);
$message_string .= "{$plugin_label} ({$tags_string}), ";
}
return trim($message_string, ' ,');
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.