diff --git a/core/modules/config_translation/src/FormElement/ElementInterface.php b/core/modules/config_translation/src/FormElement/ElementInterface.php index dd660b6..dccb982 100644 --- a/core/modules/config_translation/src/FormElement/ElementInterface.php +++ b/core/modules/config_translation/src/FormElement/ElementInterface.php @@ -28,11 +28,10 @@ public static function create(TypedDataInterface $schema); /** - * Returns the source and translation elements for a given configuration - * definition. + * Returns the translation build for a given configuration definition. * * @param \Drupal\Core\Language\LanguageInterface $source_language - * Thee source language of the configuration object. + * The source language of the configuration object. * @param \Drupal\Core\Language\LanguageInterface $translation_language * The language to display the translation form for. * @param mixed $source_config @@ -46,9 +45,10 @@ public static function create(TypedDataInterface $schema); * top-level form elements. * * @return array - * A render array for the source value. + * A render array consisting of the source and translation elements for the + * source value. */ - public function getTranslationBuild(LanguageInterface $source_language, LanguageInterface $translation_language, $source_config, $translation_config, $parents, $base_key = NULL); + public function getTranslationBuild(LanguageInterface $source_language, LanguageInterface $translation_language, $source_config, $translation_config, array $parents, $base_key = NULL); /** * Sets configuration based on a nested form value array. diff --git a/core/modules/config_translation/src/FormElement/FormElementBase.php b/core/modules/config_translation/src/FormElement/FormElementBase.php index 88d8f83..5120138 100644 --- a/core/modules/config_translation/src/FormElement/FormElementBase.php +++ b/core/modules/config_translation/src/FormElement/FormElementBase.php @@ -8,10 +8,8 @@ namespace Drupal\config_translation\FormElement; use Drupal\Core\Config\Config; -use Drupal\Core\Config\Schema\Element; use Drupal\Core\Language\LanguageInterface; use Drupal\Core\StringTranslation\StringTranslationTrait; -use Drupal\Core\TypedData\DataDefinitionInterface; use Drupal\Core\TypedData\TypedDataInterface; use Drupal\language\Config\LanguageConfigOverride; @@ -57,7 +55,7 @@ public static function create(TypedDataInterface $schema) { /** * {@inheritdoc} */ - public function getTranslationBuild(LanguageInterface $source_language, LanguageInterface $translation_language, $source_config, $translation_config, $parents, $base_key = NULL) { + public function getTranslationBuild(LanguageInterface $source_language, LanguageInterface $translation_language, $source_config, $translation_config, array $parents, $base_key = NULL) { $build['#theme'] = 'config_translation_manage_form_element'; // For accessibility we make source and translation appear next to each @@ -131,7 +129,7 @@ protected function getSourceElement(LanguageInterface $source_language, $source_ * again - the translation of this element must be disabled if the translator * does not have access to the source value of the non-translatable property. * For example, if a formatted text element, whose source format was plain - * text when it was first translated, gets changed to the full HTML format, + * text when it was first translated, gets changed to the Full HTML format, * simply changing the format of the translation would lead to an XSS * vulnerability as the translated text, that was intended to be escaped, * would now be displayed unescaped. Thus, if the translator does not have @@ -177,14 +175,15 @@ protected function getTranslationElement(LanguageInterface $translation_language * {@inheritdoc} */ public function setConfig(Config $base_config, LanguageConfigOverride $config_translation, $config_values, $base_key = NULL) { - // Save value, if different from the source value in the base - // configuration. If same as original configuration, remove override. - if ($base_config->get($base_key) !== $config_values) { - $config_translation->set($base_key, $config_values); - } - else { - $config_translation->clear($base_key); - } + // Save the form configuration values, if they are different from the source + // values in the base configuration. If the form values are the same as the + // original configuration, remove the override. + if ($base_config->get($base_key) !== $config_values) { + $config_translation->set($base_key, $config_values); } + else { + $config_translation->clear($base_key); + } + } } diff --git a/core/modules/config_translation/src/FormElement/ListElement.php b/core/modules/config_translation/src/FormElement/ListElement.php index 3481a0f..c860fd3 100644 --- a/core/modules/config_translation/src/FormElement/ListElement.php +++ b/core/modules/config_translation/src/FormElement/ListElement.php @@ -50,7 +50,7 @@ public static function create(TypedDataInterface $schema) { /** * {@inheritdoc} */ - public function getTranslationBuild(LanguageInterface $source_language, LanguageInterface $translation_language, $source_config, $translation_config, $parents, $base_key = NULL) { + public function getTranslationBuild(LanguageInterface $source_language, LanguageInterface $translation_language, $source_config, $translation_config, array $parents, $base_key = NULL) { $build = array(); foreach ($this->element as $key => $element) { $sub_build = array(); @@ -66,8 +66,8 @@ public function getTranslationBuild(LanguageInterface $source_language, Language continue; } - // Build sub-structure and include it with a wrapper in the form - // if there are any translatable elements there. + // Build the sub-structure and include it with a wrapper in the form if + // there are any translatable elements there. $build[$key] = array(); if ($element instanceof TraversableTypedDataInterface) { $build[$key] = array( @@ -109,19 +109,19 @@ public function setConfig(Config $base_config, LanguageConfigOverride $config_tr * For some configuration elements the same element structure can be repeated * multiple times (for example views displays, filters, etc.). Thus, we try to * find a more usable title for the details summary. First check if there is - * an element which is called title or label and use its value, then check if + * an element which is called title or label and use its value. Then check if * there is an element which contains these words and use those. Fall back * to the generic definition label if no such element is found. * * @param \Drupal\Core\TypedData\DataDefinitionInterface $definition - * The defintion of the schema element. - * @param $group_build + * The definition of the schema element. + * @param array $group_build * The renderable array for the group of schema elements. * * @return string * The title for the group of schema elements. */ - protected function getGroupTitle(DataDefinitionInterface $definition, $group_build) { + protected function getGroupTitle(DataDefinitionInterface $definition, array $group_build) { $title = ''; if (isset($group_build['title']['source'])) { $title = $group_build['title']['source']['#markup'];