Commit 3e336074 authored by Dries's avatar Dries

Issue #2389697 by Wim Leers, Gábor Hojtsy: Editor settings altering not needed...

Issue #2389697 by Wim Leers, Gábor Hojtsy: Editor settings altering not needed (and not compatible with config schema assumptions)
parent dfb971e4
......@@ -26,69 +26,6 @@ function hook_editor_info_alter(array &$editors) {
$editors['some_other_editor']['library']['module'] = 'myeditoroverride';
}
/**
* Provides defaults for editor instances.
*
* Modules that extend the list of settings for a particular text editor library
* should specify defaults for those settings using this hook. These settings
* will be used for any new editors, as well as merged into any existing editor
* configuration that has not yet been provided with a specific value for a
* setting (as may happen when a module providing a new setting is enabled after
* the text editor has been configured).
*
* Note that only the top-level of this array is merged into the defaults. If
* multiple modules provide nested settings with the same top-level key, only
* the first will be used. Modules should avoid deep nesting of settings to
* avoid defaults being undefined.
*
* The return value of this hook is not cached. If retrieving defaults in a
* complex manner, the implementing module should provide its own caching inside
* the hook.
*
* @param $editor
* A string indicating the name of the editor library whose default settings
* are being provided.
*
* @return array
* An array of default settings that will be merged into the editor defaults.
*/
function hook_editor_default_settings($editor) {
return array(
'mymodule_new_setting1' => TRUE,
'mymodule_new_setting2' => array(
'foo' => 'baz',
'bar' => 'qux',
),
);
}
/**
* Modifies default settings for editor instances.
*
* Modules that extend the behavior of other modules may use this hook to change
* the default settings provided to new and existing editors. This hook should
* be used when changing an existing setting to a new value. To add a new
* default setting, hook_editor_default_settings() should be used.
*
* The return value of this hook is not cached. If retrieving defaults in a
* complex manner, the implementing module should provide its own caching inside
* the hook.
*
* @param $default_settings
* The array of default settings which may be modified, passed by reference.
* @param $editor
* A string indicating the name of the editor library whose default settings
* are being provided.
*
* @return array
* An array of default settings that will be merged into the editor defaults.
*
* @see hook_editor_default_settings()
*/
function hook_editor_default_settings_alter(&$default_settings, $editor) {
$default_settings['toolbar'] = array('Bold', 'Italics', 'Underline');
}
/**
* Modifies JavaScript settings that are added for text editors.
*
......
......@@ -80,12 +80,7 @@ public function __construct(array $values, $entity_type) {
parent::__construct($values, $entity_type);
$plugin = $this->editorPluginManager()->createInstance($this->editor);
// Initialize settings, merging module-provided defaults.
$default_settings = $plugin->getDefaultSettings();
$default_settings += \Drupal::moduleHandler()->invokeAll('editor_default_settings', array($this->editor));
\Drupal::moduleHandler()->alter('editor_default_settings', $default_settings, $this->editor);
$this->settings += $default_settings;
$this->settings += $plugin->getDefaultSettings();
}
/**
......
......@@ -155,8 +155,6 @@ protected function verifyUnicornEditorConfiguration($format_id, $foo = 'bar') {
$this->assertIdentical($editor->getEditor(), 'unicorn', 'The text editor is configured correctly.');
$this->assertIdentical($settings['foo'], $foo, 'The text editor settings are stored correctly.');
$this->assertIdentical($settings['ponies_too'], true, 'The text editor defaults are retrieved correctly.');
$this->assertIdentical($settings['rainbows'], true, 'The text editor defaults added by hook_editor_settings_defaults() are retrieved correctly.');
$this->assertIdentical($settings['sparkles'], false, 'The text editor defaults modified by hook_editor_settings_defaults_alter() are retrieved correctly.');
$this->drupalGet('admin/config/content/formats/manage/'. $format_id);
$select = $this->xpath('//select[@name="editor[editor]"]');
$select_is_disabled = $this->xpath('//select[@name="editor[editor]" and @disabled="disabled"]');
......
......@@ -24,17 +24,6 @@
*/
class QuickEditIntegrationTest extends QuickEditTestBase {
/**
* Set to TRUE to strict check all configuration saved.
*
* @see \Drupal\Core\Config\Testing\ConfigSchemaChecker
*
* @todo Altering not schema compatible. https://www.drupal.org/node/2389697
*
* @var bool
*/
protected $strictConfigSchema = FALSE;
/**
* {@inheritdoc}
*/
......
......@@ -7,27 +7,6 @@
use Drupal\filter\FilterFormatInterface;
/**
* Implements hook_editor_default_settings().
*/
function editor_test_editor_default_settings($editor) {
if ($editor === 'unicorn') {
return array(
'rainbows' => TRUE,
'sparkles' => TRUE,
);
}
}
/**
* Implements hook_editor_default_settings_alter().
*/
function editor_test_editor_default_settings_alter(&$settings, $editor) {
if ($editor === 'unicorn' && isset($settings['sparkles'])) {
$settings['sparkles'] = FALSE;
}
}
/**
* Implements hook_editor_js_settings_alter().
*/
......
......@@ -52,13 +52,6 @@ class EditorConfigEntityUnitTest extends UnitTestCase {
*/
protected $editorPluginManager;
/**
* The module handler used for testing.
*
* @var \Drupal\Core\Extension\ModuleHandlerInterface|\PHPUnit_Framework_MockObject_MockObject
*/
protected $moduleHandler;
/**
* Editor plugin ID.
*
......@@ -90,24 +83,11 @@ protected function setUp() {
->disableOriginalConstructor()
->getMock();
$this->moduleHandler = $this->getMock('\Drupal\Core\Extension\ModuleHandlerInterface');
$this->moduleHandler->expects($this->once())
->method('invokeAll')
->with('editor_default_settings', array($this->editorId))
->will($this->returnValue(array()));
$this->moduleHandler->expects($this->once())
->method('alter')
->with('editor_default_settings', array(), $this->editorId)
->will($this->returnValue(array()));
$container = new ContainerBuilder();
$container->set('entity.manager', $this->entityManager);
$container->set('uuid', $this->uuid);
$container->set('plugin.manager.editor', $this->editorPluginManager);
$container->set('module_handler', $this->moduleHandler);
\Drupal::setContainer($container);
}
/**
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment