private function FundamentalCompatibilityConstraintValidator::checkHtmlRestrictionsAreCompatible in Drupal 10
Checks that fundamental CKEditor 5 plugins' HTML tags are allowed.
Parameters
\Drupal\filter\FilterFormatInterface $text_format: The text format to validate.
\Drupal\ckeditor5\Plugin\Validation\Constraint\FundamentalCompatibilityConstraint $constraint: The constraint to validate.
1 call to FundamentalCompatibilityConstraintValidator::checkHtmlRestrictionsAreCompatible()
- FundamentalCompatibilityConstraintValidator::validate in core/
modules/ ckeditor5/ src/ Plugin/ Validation/ Constraint/ FundamentalCompatibilityConstraintValidator.php
File
- core/
modules/ ckeditor5/ src/ Plugin/ Validation/ Constraint/ FundamentalCompatibilityConstraintValidator.php, line 121
Class
- FundamentalCompatibilityConstraintValidator
- Validates fundamental compatibility of CKEditor 5 with the given text format.
Namespace
Drupal\ckeditor5\Plugin\Validation\ConstraintCode
private function checkHtmlRestrictionsAreCompatible(FilterFormatInterface $text_format, FundamentalCompatibilityConstraint $constraint) : void {
$fundamental = new HTMLRestrictions($this->pluginManager
->getProvidedElements(self::FUNDAMENTAL_CKEDITOR5_PLUGINS));
$html_restrictions = $text_format
->getHtmlRestrictions();
if (!isset($html_restrictions['allowed'])) {
return;
}
if (!$fundamental
->diff(HTMLRestrictions::fromTextFormat($text_format))
->allowsNothing()) {
$offending_filter = static::findHtmlRestrictorFilterNotAllowingTags($text_format, $fundamental);
$this->context
->buildViolation($constraint->nonAllowedElementsMessage)
->setParameter('%filter_label', (string) $offending_filter
->getLabel())
->setParameter('%filter_plugin_id', $offending_filter
->getPluginId())
->addViolation();
}
}