core/lib/Drupal/Core/Config/Config.php | 19 ++++++++------- core/lib/Drupal/Core/Config/Schema/Sequence.php | 1 + .../ckeditor/Plugin/CKEditorPlugin/DrupalImage.php | 1 - .../lib/Drupal/config/Tests/ConfigSchemaTest.php | 5 ++-- core/modules/editor/editor.admin.inc | 25 -------------------- 5 files changed, 14 insertions(+), 37 deletions(-) diff --git a/core/lib/Drupal/Core/Config/Config.php b/core/lib/Drupal/Core/Config/Config.php index d17827c..e570b02 100644 --- a/core/lib/Drupal/Core/Config/Config.php +++ b/core/lib/Drupal/Core/Config/Config.php @@ -79,7 +79,7 @@ class Config { protected $isLoaded = FALSE; /** - * The config schema wrapper object for this configuration. + * The config schema wrapper object for this configuration object. * * @var \Drupal\Core\Config\Schema\Element */ @@ -422,6 +422,8 @@ public function save() { // Validate the configuration object name before saving. static::validateName($this->name); + // If there is a schema for this configuration object, cast all values to + // conform to the schema. if ($this->getTypedConfigManager()->hasConfigSchema($this->name)) { // Ensure that the schema wrapper has the latest data. $this->setSchemaWrapper(); @@ -506,14 +508,13 @@ public function getSchemaWrapper() { } /** - * Sets the schema wrapper property using the current configuration data + * Sets the schema wrapper property using the current configuration data. * * @return \Drupal\Core\Config\Config * The configuration object. */ public function setSchemaWrapper() { - $typed_config_manager = $this->getTypedConfigManager(); - $definition = $typed_config_manager->getDefinition($this->name); + $definition = $this->getTypedConfigManager()->getDefinition($this->name); $this->schemaWrapper = $typed_config_manager->create($definition, $this->data); return $this; } @@ -521,8 +522,8 @@ public function setSchemaWrapper() { /** * Gets the definition for the configuration key. * - * @param $key - * Identifier to store value in config. + * @param string $key + * A string that maps to a key within the configuration data. * * @return \Drupal\Core\Config\Schema\Element */ @@ -550,9 +551,9 @@ public function getSchemaForKey($key) { * Gets the value with the correct data type for this config object. * * @param string $key - * Identifier to store value in config. + * A string that maps to a key within the configuration data. * @param string $value - * Value to associate with identifier. + * Value to associate with the key. * * @return mixed * The value cast to the type indicated in the schema. @@ -597,7 +598,6 @@ public function getTypedValue($key, $value) { return $value; } - /** * Returns the typed config manager service. * @@ -613,4 +613,5 @@ protected function getTypedConfigManager() { } return $this->typedConfigManager; } + } diff --git a/core/lib/Drupal/Core/Config/Schema/Sequence.php b/core/lib/Drupal/Core/Config/Schema/Sequence.php index 832c5ec..b5f5a75 100644 --- a/core/lib/Drupal/Core/Config/Schema/Sequence.php +++ b/core/lib/Drupal/Core/Config/Schema/Sequence.php @@ -63,4 +63,5 @@ public function get($key) { $elements = $this->parse(); return $elements[$key]; } + } diff --git a/core/modules/ckeditor/lib/Drupal/ckeditor/Plugin/CKEditorPlugin/DrupalImage.php b/core/modules/ckeditor/lib/Drupal/ckeditor/Plugin/CKEditorPlugin/DrupalImage.php index 7e95109..12ce8e4 100644 --- a/core/modules/ckeditor/lib/Drupal/ckeditor/Plugin/CKEditorPlugin/DrupalImage.php +++ b/core/modules/ckeditor/lib/Drupal/ckeditor/Plugin/CKEditorPlugin/DrupalImage.php @@ -84,7 +84,6 @@ public function settingsForm(array $form, array &$form_state, Editor $editor) { * * @see \Drupal\editor\Form\EditorImageDialog * @see editor_image_upload_settings_form() - * @see editor_image_upload_settings_validate() */ function validateImageUploadSettings(array $element, array &$form_state) { $settings = &$form_state['values']['editor']['settings']['plugins']['drupalimage']['image_upload']; diff --git a/core/modules/config/lib/Drupal/config/Tests/ConfigSchemaTest.php b/core/modules/config/lib/Drupal/config/Tests/ConfigSchemaTest.php index 9eca659..a2b7db1 100644 --- a/core/modules/config/lib/Drupal/config/Tests/ConfigSchemaTest.php +++ b/core/modules/config/lib/Drupal/config/Tests/ConfigSchemaTest.php @@ -249,12 +249,12 @@ function testSchemaData() { /** * Test configuration value data type enforcement using schemas. */ - protected function testConfigSaveWithSchema () { + public function testConfigSaveWithSchema () { $untyped_values = array( 'string' => 1, 'integer' => '100', 'boolean' => 1, - // In the config schema this does not have a type so should cast to string. + // In the config schema this doesn't have a type so should cast to string. 'no_type' => 1, 'array' => array( 'string' => 1 @@ -286,4 +286,5 @@ protected function testConfigSaveWithSchema () { ->save(); $this->assertIdentical(\Drupal::config('config_test.no_schema_data_types')->get(), $untyped_values); } + } diff --git a/core/modules/editor/editor.admin.inc b/core/modules/editor/editor.admin.inc index eed9761..a29924b 100644 --- a/core/modules/editor/editor.admin.inc +++ b/core/modules/editor/editor.admin.inc @@ -128,30 +128,5 @@ function editor_image_upload_settings_form(Editor $editor) { '#states' => $show_if_image_uploads_enabled, ); - $form['#element_validate'] = array( - 'editor_image_upload_settings_validate', - ); - return $form; } - -/** - * #element_validate handler for editor_image_upload_settings_validate(). - * - * Ensures each form item's value is cast to the proper type. - * - * @see \Drupal\editor\Form\EditorImageDialog - * @ingroup forms - */ -function editor_image_upload_settings_validate(array $element, array &$form_state) { - $cast_value = function($type, $element) use (&$form_state) { - $section = $element['#parents']; - $value = NestedArray::getValue($form_state['values'], $section); - settype($value, $type); - NestedArray::setValue($form_state['values'], $section, $value); - }; - - $cast_value('bool', $element['status']); - $cast_value('int', $element['max_dimensions']['width']); - $cast_value('int', $element['max_dimensions']['height']); -}