public function FundamentalCompatibilityConstraintValidator::validate in Drupal 10
Throws
\Symfony\Component\Validator\Exception\UnexpectedTypeException Thrown when the given constraint is not supported by this validator.
File
- core/
modules/ ckeditor5/ src/ Plugin/ Validation/ Constraint/ FundamentalCompatibilityConstraintValidator.php, line 55
Class
- FundamentalCompatibilityConstraintValidator
- Validates fundamental compatibility of CKEditor 5 with the given text format.
Namespace
Drupal\ckeditor5\Plugin\Validation\ConstraintCode
public function validate($toolbar_item, Constraint $constraint) {
if (!$constraint instanceof FundamentalCompatibilityConstraint) {
throw new UnexpectedTypeException($constraint, __NAMESPACE__ . '\\FundamentalCompatibility');
}
$text_editor = $this
->createTextEditorObjectFromContext();
// First: the two fundamental checks against the text format. If any of
// them adds a constraint violation, return early, because it is a
// fundamental compatibility problem.
$this
->checkNoMarkupFilters($text_editor
->getFilterFormat(), $constraint);
if ($this->context
->getViolations()
->count() > 0) {
return;
}
$this
->checkHtmlRestrictionsAreCompatible($text_editor
->getFilterFormat(), $constraint);
if ($this->context
->getViolations()
->count() > 0) {
return;
}
// Second: ensure that all tags can actually be created.
$this
->checkAllHtmlTagsAreCreatable($text_editor, $constraint);
// Finally: ensure the CKEditor 5 configuration's ability to generate HTML
// markup precisely matches that of the text format.
$this
->checkHtmlRestrictionsMatch($text_editor, $constraint);
}