function Contrib::mapCKEditor4SettingsToCKEditor5Configuration

Same name in other branches
  1. 9 core/modules/ckeditor5/src/Plugin/CKEditor4To5Upgrade/Contrib.php \Drupal\ckeditor5\Plugin\CKEditor4To5Upgrade\Contrib::mapCKEditor4SettingsToCKEditor5Configuration()
  2. 10 core/modules/ckeditor5/src/Plugin/CKEditor4To5Upgrade/Contrib.php \Drupal\ckeditor5\Plugin\CKEditor4To5Upgrade\Contrib::mapCKEditor4SettingsToCKEditor5Configuration()

Overrides CKEditor4To5UpgradePluginInterface::mapCKEditor4SettingsToCKEditor5Configuration

File

core/modules/ckeditor5/src/Plugin/CKEditor4To5Upgrade/Contrib.php, line 56

Class

Contrib
Provides the CKEditor 4 to 5 upgrade path for contrib plugins now in core.

Namespace

Drupal\ckeditor5\Plugin\CKEditor4To5Upgrade

Code

public function mapCKEditor4SettingsToCKEditor5Configuration(string $cke4_plugin_id, array $cke4_plugin_settings) : ?array {
    switch ($cke4_plugin_id) {
        case 'codesnippet':
            $languages = [];
            $enabled_cke4_languages = array_filter($cke4_plugin_settings['highlight_languages']);
            foreach ($enabled_cke4_languages as $language) {
                $languages[] = [
                    'language' => $language,
                    'label' => $language,
                ];
            }
            return [
                'ckeditor5_codeBlock' => [
                    'languages' => $languages,
                ],
            ];
        default:
            throw new \OutOfBoundsException();
    }
}

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