diff --git a/core/modules/ckeditor/lib/Drupal/ckeditor/CKEditorPluginManager.php b/core/modules/ckeditor/lib/Drupal/ckeditor/CKEditorPluginManager.php index da2bcfd8a713e44c4980a5bf5ca52b1602928646..555eae390b8b3ccd8a48703f448f4ad0acba072d 100644 --- a/core/modules/ckeditor/lib/Drupal/ckeditor/CKEditorPluginManager.php +++ b/core/modules/ckeditor/lib/Drupal/ckeditor/CKEditorPluginManager.php @@ -40,7 +40,7 @@ public function __construct(\Traversable $namespaces, CacheBackendInterface $cac } /** - * Determines which plug-ins are enabled. + * Retrieves enabled plugins' files, keyed by plugin ID. * * For CKEditor plugins that implement: * - CKEditorPluginButtonsInterface, not CKEditorPluginContextualInterface, @@ -64,7 +64,7 @@ public function __construct(\Traversable $namespaces, CacheBackendInterface $cac * the Drupal root-relative plugin files as values. * For internal plugins, the value is NULL. */ - public function getEnabledPlugins(Editor $editor, $include_internal_plugins = FALSE) { + public function getEnabledPluginFiles(Editor $editor, $include_internal_plugins = FALSE) { $plugins = array_keys($this->getDefinitions()); $toolbar_buttons = array_unique(NestedArray::mergeDeepArray($editor->settings['toolbar']['buttons'])); $enabled_plugins = array(); @@ -108,16 +108,15 @@ public function getEnabledPlugins(Editor $editor, $include_internal_plugins = FA } /** - * Retrieves all plugins that implement CKEditorPluginButtonsInterface. + * Retrieves all available CKEditor buttons, keyed by plugin ID. * * @return array - * A list of the CKEditor plugins that implement buttons, with the plugin - * IDs as keys and lists of button metadata (as implemented by getButtons()) - * as values. + * All availble CKEditor buttons, with plugin IDs as keys and button + * metadata (as implemented by getButtons()) as values. * * @see CKEditorPluginButtonsInterface::getButtons() */ - public function getButtonsPlugins() { + public function getButtons() { $plugins = array_keys($this->getDefinitions()); $buttons_plugins = array(); diff --git a/core/modules/ckeditor/lib/Drupal/ckeditor/Plugin/Editor/CKEditor.php b/core/modules/ckeditor/lib/Drupal/ckeditor/Plugin/Editor/CKEditor.php index 5b79bf2561dca55863f58b121b90ec6faf6862cd..eca1381a7ac92155b4717ac1e58403bbbd337a4c 100644 --- a/core/modules/ckeditor/lib/Drupal/ckeditor/Plugin/Editor/CKEditor.php +++ b/core/modules/ckeditor/lib/Drupal/ckeditor/Plugin/Editor/CKEditor.php @@ -86,7 +86,7 @@ public function settingsForm(array $form, array &$form_state, EditorEntity $edit $ckeditor_settings_toolbar = array( '#theme' => 'ckeditor_settings_toolbar', '#editor' => $editor, - '#plugins' => $this->ckeditorPluginManager->getButtonsPlugins(), + '#plugins' => $this->ckeditorPluginManager->getButtons(), ); $form['toolbar'] = array( '#type' => 'container', @@ -135,7 +135,7 @@ public function settingsForm(array $form, array &$form_state, EditorEntity $edit } } // Get a list of all buttons that are provided by all plugins. - $all_buttons = array_reduce($this->ckeditorPluginManager->getButtonsPlugins(), function($result, $item) { + $all_buttons = array_reduce($this->ckeditorPluginManager->getButtons(), function($result, $item) { return array_merge($result, array_keys($item)); }, array()); // Build a fake Editor object, which we'll use to generate JavaScript @@ -196,18 +196,18 @@ public function getJSSettings(EditorEntity $editor) { $settings = array(); // Get the settings for all enabled plugins, even the internal ones. - $enabled_plugins = array_keys($this->ckeditorPluginManager->getEnabledPlugins($editor, TRUE)); + $enabled_plugins = array_keys($this->ckeditorPluginManager->getEnabledPluginFiles($editor, TRUE)); foreach ($enabled_plugins as $plugin_id) { $plugin = $this->ckeditorPluginManager->createInstance($plugin_id); $settings += $plugin->getConfig($editor); } // Next, set the most fundamental CKEditor settings. - $external_plugins = $this->ckeditorPluginManager->getEnabledPlugins($editor); + $external_plugin_files = $this->ckeditorPluginManager->getEnabledPluginFiles($editor); $settings += array( 'toolbar' => $this->buildToolbarJSSetting($editor), 'contentsCss' => $this->buildContentsCssJSSetting($editor), - 'extraPlugins' => implode(',', array_keys($external_plugins)), + 'extraPlugins' => implode(',', array_keys($external_plugin_files)), // @todo: Remove image and link plugins from CKEditor build. 'removePlugins' => 'image,link', 'language' => $language_interface->id, @@ -221,7 +221,7 @@ public function getJSSettings(EditorEntity $editor) { // Finally, set Drupal-specific CKEditor settings. $settings += array( - 'drupalExternalPlugins' => array_map('file_create_url', $external_plugins), + 'drupalExternalPlugins' => array_map('file_create_url', $external_plugin_files), ); ksort($settings); @@ -238,7 +238,7 @@ public function getLibraries(EditorEntity $editor) { ); // Get the required libraries for any enabled plugins. - $enabled_plugins = array_keys($this->ckeditorPluginManager->getEnabledPlugins($editor)); + $enabled_plugins = array_keys($this->ckeditorPluginManager->getEnabledPluginFiles($editor)); foreach ($enabled_plugins as $plugin_id) { $plugin = $this->ckeditorPluginManager->createInstance($plugin_id); $additional_libraries = array_udiff($plugin->getLibraries($editor), $libraries, function($a, $b) { diff --git a/core/modules/ckeditor/lib/Drupal/ckeditor/Tests/CKEditorPluginManagerTest.php b/core/modules/ckeditor/lib/Drupal/ckeditor/Tests/CKEditorPluginManagerTest.php index 3d31c041e55cf705a6ce972658f2947d8749df10..cee1e752400870664cbfa502a78526189600bfcf 100644 --- a/core/modules/ckeditor/lib/Drupal/ckeditor/Tests/CKEditorPluginManagerTest.php +++ b/core/modules/ckeditor/lib/Drupal/ckeditor/Tests/CKEditorPluginManagerTest.php @@ -74,8 +74,8 @@ function testEnabledPlugins() { 'drupalimage' => 'core/modules/ckeditor/js/plugins/drupalimage/plugin.js', 'drupallink' => 'core/modules/ckeditor/js/plugins/drupallink/plugin.js', ); - $this->assertIdentical($enabled_plugins, $this->manager->getEnabledPlugins($editor), 'Only built-in plugins are enabled.'); - $this->assertIdentical(array('internal' => NULL) + $enabled_plugins, $this->manager->getEnabledPlugins($editor, TRUE), 'Only the "internal" plugin is enabled.'); + $this->assertIdentical($enabled_plugins, $this->manager->getEnabledPluginFiles($editor), 'Only built-in plugins are enabled.'); + $this->assertIdentical(array('internal' => NULL) + $enabled_plugins, $this->manager->getEnabledPluginFiles($editor, TRUE), 'Only the "internal" plugin is enabled.'); // Enable the CKEditor Test module, which has the Llama plugin (plus three // variations of it, to cover all possible ways a plugin can be enabled) and @@ -87,8 +87,8 @@ function testEnabledPlugins() { $plugin_ids = array_keys($this->manager->getDefinitions()); sort($plugin_ids); $this->assertIdentical(array('drupalimage', 'drupallink', 'internal', 'llama', 'llama_button', 'llama_contextual', 'llama_contextual_and_button', 'stylescombo'), $plugin_ids, 'Additional CKEditor plugins found.'); - $this->assertIdentical($enabled_plugins, $this->manager->getEnabledPlugins($editor), 'Only the internal plugins are enabled.'); - $this->assertIdentical(array('internal' => NULL) + $enabled_plugins, $this->manager->getEnabledPlugins($editor, TRUE), 'Only the "internal" plugin is enabled.'); + $this->assertIdentical($enabled_plugins, $this->manager->getEnabledPluginFiles($editor), 'Only the internal plugins are enabled.'); + $this->assertIdentical(array('internal' => NULL) + $enabled_plugins, $this->manager->getEnabledPluginFiles($editor, TRUE), 'Only the "internal" plugin is enabled.'); // Case 3: enable each of the newly available plugins, if possible: // a. Llama: cannot be enabled, since it does not implement @@ -111,19 +111,19 @@ function testEnabledPlugins() { $file['c'] = 'core/modules/ckeditor/tests/modules/js/llama_contextual.js'; $file['cb'] = 'core/modules/ckeditor/tests/modules/js/llama_contextual_and_button.js'; $expected = $enabled_plugins + array('llama_button' => $file['b'], 'llama_contextual_and_button' => $file['cb']); - $this->assertIdentical($expected, $this->manager->getEnabledPlugins($editor), 'The LlamaButton and LlamaContextualAndButton plugins are enabled.'); - $this->assertIdentical(array('internal' => NULL) + $expected, $this->manager->getEnabledPlugins($editor, TRUE), 'The LlamaButton and LlamaContextualAndButton plugins are enabled.'); + $this->assertIdentical($expected, $this->manager->getEnabledPluginFiles($editor), 'The LlamaButton and LlamaContextualAndButton plugins are enabled.'); + $this->assertIdentical(array('internal' => NULL) + $expected, $this->manager->getEnabledPluginFiles($editor, TRUE), 'The LlamaButton and LlamaContextualAndButton plugins are enabled.'); $editor->settings['toolbar']['buttons'][0] = $original_toolbar; $editor->settings['toolbar']['buttons'][0][] = 'Strike'; $editor->save(); $expected = $enabled_plugins + array('llama_contextual' => $file['c'], 'llama_contextual_and_button' => $file['cb']); - $this->assertIdentical($expected, $this->manager->getEnabledPlugins($editor), 'The LLamaContextual and LlamaContextualAndButton plugins are enabled.'); - $this->assertIdentical(array('internal' => NULL) + $expected, $this->manager->getEnabledPlugins($editor, TRUE), 'The LlamaContextual and LlamaContextualAndButton plugins are enabled.'); + $this->assertIdentical($expected, $this->manager->getEnabledPluginFiles($editor), 'The LLamaContextual and LlamaContextualAndButton plugins are enabled.'); + $this->assertIdentical(array('internal' => NULL) + $expected, $this->manager->getEnabledPluginFiles($editor, TRUE), 'The LlamaContextual and LlamaContextualAndButton plugins are enabled.'); $editor->settings['toolbar']['buttons'][0][] = 'Llama'; $editor->save(); $expected = $enabled_plugins + array('llama_button' => $file['b'], 'llama_contextual' => $file['c'], 'llama_contextual_and_button' => $file['cb']); - $this->assertIdentical($expected, $this->manager->getEnabledPlugins($editor), 'The LlamaButton, LlamaContextual and LlamaContextualAndButton plugins are enabled.'); - $this->assertIdentical(array('internal' => NULL) + $expected, $this->manager->getEnabledPlugins($editor, TRUE), 'The LLamaButton, LlamaContextual and LlamaContextualAndButton plugins are enabled.'); + $this->assertIdentical($expected, $this->manager->getEnabledPluginFiles($editor), 'The LlamaButton, LlamaContextual and LlamaContextualAndButton plugins are enabled.'); + $this->assertIdentical(array('internal' => NULL) + $expected, $this->manager->getEnabledPluginFiles($editor, TRUE), 'The LLamaButton, LlamaContextual and LlamaContextualAndButton plugins are enabled.'); } }