function CKEditor4To5UpgradePluginManager::mapCKEditor4SettingsToCKEditor5Configuration

Same name in other branches
  1. 10 core/modules/ckeditor5/src/Plugin/CKEditor4To5UpgradePluginManager.php \Drupal\ckeditor5\Plugin\CKEditor4To5UpgradePluginManager::mapCKEditor4SettingsToCKEditor5Configuration()
  2. 11.x core/modules/ckeditor5/src/Plugin/CKEditor4To5UpgradePluginManager.php \Drupal\ckeditor5\Plugin\CKEditor4To5UpgradePluginManager::mapCKEditor4SettingsToCKEditor5Configuration()

Maps CKEditor 4 settings to the CKEditor 5 equivalent, if needed.

Not every CKEditor 5 plugin has settings; some CKEditor 5 plugins may have settings that the CKEditor 4 equivalent did not and vice versa. Therefore the complete CKEditor 4 settings are provided, and any CKEditor 5 setting can be set.

Parameters

string $cke4_plugin_id: The CKEditor 4 plugin whose settings need to be mapped.

array $cke4_plugin_settings: The settings for this CKEditor 4 plugin.

Return value

array|null NULL if not needed, otherwise an array with a single key-value pair:

  • key: the plugin ID of the equivalent CKEditor 5 plugin
  • value: the equivalent settings

Throws

\OutOfBoundsException Thrown when no upgrade path exists.

\LogicException Thrown when a plugin claims to provide an upgrade path but does not.

See also

\Drupal\ckeditor\CKEditorPluginConfigurableInterface

File

core/modules/ckeditor5/src/Plugin/CKEditor4To5UpgradePluginManager.php, line 175

Class

CKEditor4To5UpgradePluginManager
Provides a CKEditor 4 to 5 upgrade plugin manager.

Namespace

Drupal\ckeditor5\Plugin

Code

public function mapCKEditor4SettingsToCKEditor5Configuration(string $cke4_plugin_id, array $cke4_plugin_settings) : ?array {
    $this->validateAndBuildMaps();
    if (!isset($this->cke4PluginSettingsMap[$cke4_plugin_id])) {
        throw new \OutOfBoundsException(sprintf('No upgrade path found for the "%s" plugin settings.', $cke4_plugin_id));
    }
    $plugin_id = $this->cke4PluginSettingsMap[$cke4_plugin_id];
    try {
        return $this->createInstance($plugin_id)
            ->mapCKEditor4SettingsToCKEditor5Configuration($cke4_plugin_id, $cke4_plugin_settings);
    } catch (\OutOfBoundsException $e) {
        throw new \LogicException(sprintf('The "%s" CKEditor4To5Upgrade plugin claims to provide an upgrade path for the "%s" CKEditor 4 plugin settings but does not.', $plugin_id, $cke4_plugin_id));
    }
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.