/**
* {@inheritdoc}
*
* @throws \Symfony\Component\Validator\Exception\UnexpectedTypeException
* Thrown when the given constraint is not supported by this validator.
*/
public function validate($toolbar_item, Constraint
$constraint) { if (!
$constraint instanceof CKEditor5MediaAndFilterSettingsInSyncConstraint
) { throw new UnexpectedTypeException($constraint, __NAMESPACE__ . '\CKEditor5MediaAndFilterSettingsInSync'
);
} $text_editor =
$this->
createTextEditorObjectFromContext();
if (isset($text_editor->
getSettings()['plugins'
]['media_media'
])) { $cke5_plugin_overrides_allowed =
$text_editor->
getSettings()['plugins'
]['media_media'
]['allow_view_mode_override'
];
$filter_allowed_view_modes =
$text_editor->
getFilterFormat()->
filters('media_embed'
)->
getConfiguration()['settings'
]['allowed_view_modes'
];
$filter_media_plugin_label =
$this->filterPluginManager->
getDefinition('media_embed'
)['title'
]->
render();
$filter_media_allowed_view_modes_label =
$this->typedConfigManager->
getDefinition('filter_settings.media_embed'
)['mapping'
]['allowed_view_modes'
]['label'
];
// Whenever the CKEditor 5 plugin is configured to allow overrides, the
// filter must be configured to allow 2 or more view modes.
if ($cke5_plugin_overrides_allowed &&
count($filter_allowed_view_modes) < 2
) { $this->context->
addViolation($constraint->message,
[