/**
* {@inheritdoc}
*
* @throws \Symfony\Component\Validator\Exception\UnexpectedTypeException
* Thrown when the given constraint is not supported by this validator.
*/
public function validate($element, Constraint
$constraint) { if (!
$constraint instanceof StyleSensibleElementConstraint
) { throw new UnexpectedTypeException($constraint, StyleSensibleElementConstraint::
class);
} // The preceding constraints (in this case: CKEditor5Element) must be valid.
if ($this->
hasViolationsForPrecedingConstraints($constraint)) { return;
} $text_editor =
$this->
createTextEditorObjectFromContext();
// The single tag for which a style is specified, which we are checking now.
$style_element = HTMLRestrictions::
fromString($element);
assert(count($style_element->
getAllowedElements()) === 1
);
[$tag,
$classes] = Style::
getTagAndClasses($style_element);
// Ensure the tag is in the range supported by the Style plugin.