if (isset($definition['drupal'
]['class'
]) && !
class_exists($definition['drupal'
]['class'
])) { throw new InvalidPluginDefinitionException($id,
sprintf('The CKEditor 5 "%s" provides a plugin class: "%s", but it does not exist.',
$id,
$definition['drupal'
]['class'
]));
} elseif (isset($definition['drupal'
]['class'
]) && !
in_array(CKEditor5PluginInterface::
class,
class_implements($definition['drupal'
]['class'
]))) { throw new InvalidPluginDefinitionException($id,
sprintf('CKEditor 5 plugins must implement \Drupal\ckeditor5\Plugin\CKEditor5PluginInterface. "%s" does not.',
$id));
} elseif (in_array(CKEditor5PluginConfigurableInterface::
class,
class_implements($definition['drupal'
]['class'
], TRUE
))) { $default_configuration =
(new \
ReflectionClass($definition['drupal'
]['class'
])) ->
newInstanceWithoutConstructor() ->
defaultConfiguration();
if (!
empty($default_configuration)) { $configuration_name =
sprintf("ckeditor5.plugin.%s",
$definition['id'
]);
if (!
$this->
getTypedConfig()->
hasConfigSchema($configuration_name)) { throw new InvalidPluginDefinitionException($id,
sprintf('The "%s" CKEditor 5 plugin definition is configurable, has non-empty default configuration but has no config schema. Config schema is required for validation.',
$id));
} $error_message =
$this->
validateConfiguration($default_configuration);
if ($error_message) { throw new InvalidPluginDefinitionException($id,
sprintf('The "%s" CKEditor 5 plugin definition is configurable, but its default configuration does not match its config schema. %s',
$id,
$error_message));
} } }