function CKEditor5PluginDefinition::__construct
Same name and namespace in other branches
- 11.x core/modules/ckeditor5/src/Plugin/CKEditor5PluginDefinition.php \Drupal\ckeditor5\Plugin\CKEditor5PluginDefinition::__construct()
- 10 core/modules/ckeditor5/src/Plugin/CKEditor5PluginDefinition.php \Drupal\ckeditor5\Plugin\CKEditor5PluginDefinition::__construct()
- 9 core/modules/ckeditor5/src/Plugin/CKEditor5PluginDefinition.php \Drupal\ckeditor5\Plugin\CKEditor5PluginDefinition::__construct()
CKEditor5PluginDefinition constructor.
Parameters
array $definition: An array of values from the annotation/YAML.
Throws
\InvalidArgumentException
File
-
core/
modules/ ckeditor5/ src/ Plugin/ CKEditor5PluginDefinition.php, line 46
Class
- CKEditor5PluginDefinition
- Provides an implementation of a CKEditor 5 plugin definition.
Namespace
Drupal\ckeditor5\PluginCode
public function __construct(array $definition) {
foreach ($definition as $property => $value) {
if (property_exists($this, $property)) {
$this->{$property} = $value;
}
else {
throw new \InvalidArgumentException(sprintf('Property %s with value %s does not exist on %s.', $property, $value, __CLASS__));
}
}
// In version CKEditor5 45.0.0, the icons were renamed, so if any
// drupalElementStyles are specifying icons, deprecate use of the old names
// and provide a mapping for backwards compatibility.
// @see https://ckeditor.com/docs/ckeditor5/latest/updating/guides/changelog.html#new-installation-methods-improvements-icons-replacement
// @see https://github.com/ckeditor/ckeditor5/blob/v44.3.0/packages/ckeditor5-core/src/index.ts
// @see https://github.com/ckeditor/ckeditor5/blob/v45.0.0/packages/ckeditor5-icons/src/index.ts
if (!isset($this->ckeditor5) || !isset($this->ckeditor5['config']['drupalElementStyles']) || !is_array($this->ckeditor5['config']['drupalElementStyles'])) {
return;
}
foreach ($this->ckeditor5['config']['drupalElementStyles'] as $group_id => &$groups) {
if (!is_array($groups)) {
continue;
}
foreach ($groups as &$style) {
if (is_array($style) && isset($style['icon']) && is_string($style['icon']) && !preg_match('/^(<svg)|(Icon)/', $style['icon'])) {
$deprecated_icon = $style['icon'];
$style['icon'] = match ($deprecated_icon) { 'objectLeft' => 'IconObjectInlineLeft',
'objectRight' => 'IconObjectInlineRight',
'objectBlockLeft' => 'IconObjectLeft',
'objectBlockRight' => 'IconObjectRight',
default => 'Icon' . ucfirst($style['icon']),
};
@trigger_error(sprintf('The icon configuration value "%s" in drupalElementStyles group %s for CKEditor5 plugin %s is deprecated in drupal:11.2.0 and will be removed in drupal:12.0.0. Try using "%s" instead. See https://www.drupal.org/node/3528806', $deprecated_icon, $group_id, $this->id(), $style['icon']), E_USER_DEPRECATED);
}
}
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.