function FundamentalCompatibilityConstraintValidator::checkHtmlRestrictionsAreCompatible

Same name in other branches
  1. 10 core/modules/ckeditor5/src/Plugin/Validation/Constraint/FundamentalCompatibilityConstraintValidator.php \Drupal\ckeditor5\Plugin\Validation\Constraint\FundamentalCompatibilityConstraintValidator::checkHtmlRestrictionsAreCompatible()
  2. 11.x core/modules/ckeditor5/src/Plugin/Validation/Constraint/FundamentalCompatibilityConstraintValidator.php \Drupal\ckeditor5\Plugin\Validation\Constraint\FundamentalCompatibilityConstraintValidator::checkHtmlRestrictionsAreCompatible()

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\Constraint

Code

private function checkHtmlRestrictionsAreCompatible(FilterFormatInterface $text_format, FundamentalCompatibilityConstraint $constraint) : void {
    $html_restrictions = HTMLRestrictions::fromTextFormat($text_format);
    if ($html_restrictions->isUnrestricted()) {
        return;
    }
    $fundamental = new HTMLRestrictions($this->pluginManager
        ->getProvidedElements(self::FUNDAMENTAL_CKEDITOR5_PLUGINS));
    if (!$fundamental->diff($html_restrictions)
        ->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();
    }
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.