diff --git a/config_translation.module b/config_translation.module index cafb935..2579489 100644 --- a/config_translation.module +++ b/config_translation.module @@ -144,8 +144,8 @@ function config_translation_find_translatable($schema) { * Language code string. */ function config_translation_original_langcode($name) { - $configuration = config($name)->get(); - return isset($configuration['langcode']) ? $configuration['langcode'] : 'en'; + $config = config($name)->get(); + return isset($config['langcode']) ? $config['langcode'] : 'en'; } /** diff --git a/lib/Drupal/config_translation/Form/ConfigTranslationManageForm.php b/lib/Drupal/config_translation/Form/ConfigTranslationManageForm.php index aca4efc..bad96f3 100644 --- a/lib/Drupal/config_translation/Form/ConfigTranslationManageForm.php +++ b/lib/Drupal/config_translation/Form/ConfigTranslationManageForm.php @@ -80,14 +80,14 @@ class ConfigTranslationManageForm implements FormInterface { * The configuration group the form is being built for. * @param Language $language * The language the form is adding or editing. - * @param array $base_configuration_data + * @param array $base_config_data * The base configuration in the source language. */ - public function buildForm(array $form, array &$form_state, ConfigMapperInterface $group = NULL, Language $language = NULL, array $base_configuration_data = NULL) { + public function buildForm(array $form, array &$form_state, ConfigMapperInterface $group = NULL, Language $language = NULL, array $base_config_data = NULL) { $this->group = $group; $this->language = $language; $this->sourceLanguage = $this->group->getConfigGroup()->getLanguageWithFallback(); - $this->baseConfigData = $base_configuration_data; + $this->baseConfigData = $base_config_data; foreach ($this->group->getNames() as $id => $name) { $form[$id] = array( @@ -120,19 +120,19 @@ class ConfigTranslationManageForm implements FormInterface { foreach ($this->group->getNames() as $id => $name) { // Set configuration values based on form submission and source values. - $base_configuration = config($name); - $translation_configuration = config('locale.config.' . $this->language->id . '.' . $name); + $base_config = config($name); + $translation_config = config('locale.config.' . $this->language->id . '.' . $name); $locations = $this->localeStorage->getLocations(array('type' => 'configuration', 'name' => $name)); - $this->setConfig($this->language, $base_configuration, $translation_configuration, $form_values[$id], !empty($locations)); + $this->setConfig($this->language, $base_config, $translation_config, $form_values[$id], !empty($locations)); // If no overrides, delete language specific configuration file. - $saved_configuration = $translation_configuration->get(); - if (empty($saved_configuration)) { - $translation_configuration->delete(); + $saved_config = $translation_config->get(); + if (empty($saved_config)) { + $translation_config->delete(); } else { - $translation_configuration->save(); + $translation_config->save(); } } @@ -149,10 +149,10 @@ class ConfigTranslationManageForm implements FormInterface { * Schema definition of configuration which is a * \Drupal\Core\Config\Schema\Element or a * \Drupal\Core\TypedData\TypedConfigManager. - * @param array|string $configuration_data + * @param array|string $config_data * Configuration object of requested language, a string when done traversing * the data building each sub-structure for the form. - * @param array|string $base_configuration_data + * @param array|string $base_config_data * Configuration object of base language, a string when done traversing * the data building each sub-structure for the form. * @param bool $collapsed @@ -166,7 +166,7 @@ class ConfigTranslationManageForm implements FormInterface { * @todo Make this conditional on the translatable schema property from * http://drupal.org/node/2035393 - currently hardcodes label and text. */ - protected function buildConfigForm($schema, $configuration_data, $base_configuration_data, $collapsed = FALSE, $base_key = '') { + protected function buildConfigForm($schema, $config_data, $base_config_data, $collapsed = FALSE, $base_key = '') { $build = array(); foreach ($schema as $key => $element) { // Make the specific element key, "$base_key.$key". @@ -175,7 +175,7 @@ class ConfigTranslationManageForm implements FormInterface { if ($element instanceof Element) { // Build sub-structure and include it with a wrapper in the form // if there are any translatable elements there. - $sub_build = $this->buildConfigForm($element, $configuration_data[$key], $base_configuration_data[$key], TRUE, $element_key); + $sub_build = $this->buildConfigForm($element, $config_data[$key], $base_config_data[$key], TRUE, $element_key); if (!empty($sub_build)) { // For some configuration elements the same element structure can // repeat multiple times, (like views displays, filters, etc.). @@ -213,12 +213,12 @@ class ConfigTranslationManageForm implements FormInterface { continue; } - $value = $configuration_data[$key]; + $value = $config_data[$key]; $build[$element_key] = array( '#theme' => 'config_translation_manage_form_element', ); $build[$element_key]['source'] = array( - '#markup' => $base_configuration_data[$key] ? ('' . nl2br($base_configuration_data[$key] . '')) : t('(Empty)'), + '#markup' => $base_config_data[$key] ? ('' . nl2br($base_config_data[$key] . '')) : t('(Empty)'), '#title' => t($definition['label']) . ' ('. $this->sourceLanguage->name . ')', '#type' => 'item', ); @@ -245,12 +245,12 @@ class ConfigTranslationManageForm implements FormInterface { * * @param \Drupal\Core\Language\Language $language * Set the configuration in this language. - * @param \Drupal\Core\Config\Config $base_configuration + * @param \Drupal\Core\Config\Config $base_config * Base configuration values, in the source language. - * @param \Drupal\Core\Config\Config $translation_configuration + * @param \Drupal\Core\Config\Config $translation_config * Translation configuration instance. Values from $config_values will be * set in this instance. - * @param array $configuration_values + * @param array $config_values * A simple one dimensional or recursive array: * - simple: * array(name => array('translation' => 'French site name')); @@ -261,22 +261,22 @@ class ConfigTranslationManageForm implements FormInterface { * ); * Either format is used, the nested arrays are just containers and not * needed for saving the data. - * @param bool $shipped_configuration + * @param bool $shipped_config * Flag to specify whether the configuration had a shipped version and * therefore should also be stored in the locale database. */ - protected function setConfig(Language $language, Config $base_configuration, Config $translation_configuration, array $configuration_values, $shipped_configuration = FALSE) { - foreach ($configuration_values as $key => $value) { + protected function setConfig(Language $language, Config $base_config, Config $translation_config, array $config_values, $shipped_config = FALSE) { + foreach ($config_values as $key => $value) { if (is_array($value) && !isset($value['translation'])) { // Traverse into this level in the configuration. - $this->setConfig($language, $base_configuration, $translation_configuration, $value, $shipped_configuration); + $this->setConfig($language, $base_config, $translation_config, $value, $shipped_config); } else { // If the configuration file being translated was originally shipped, we // should update the locale translation storage. The string should // already be there, but we make sure to check. - if ($shipped_configuration && $source_string = $this->localeStorage->findString(array('source' => $base_configuration->get($key)))) { + if ($shipped_config && $source_string = $this->localeStorage->findString(array('source' => $base_config->get($key)))) { // Get the translation for this original source string from locale. $conditions = array( @@ -298,11 +298,11 @@ class ConfigTranslationManageForm implements FormInterface { // Save value, if different from the source value in the base // configuration. If same as original configuration, remove override. - if ($base_configuration->get($key) !== $value['translation']) { - $translation_configuration->set($key, $value['translation']); + if ($base_config->get($key) !== $value['translation']) { + $translation_config->set($key, $value['translation']); } else { - $translation_configuration->clear($key); + $translation_config->clear($key); } } }