diff --git a/core/modules/language/language.module b/core/modules/language/language.module index f68d186..e6147eb 100644 --- a/core/modules/language/language.module +++ b/core/modules/language/language.module @@ -274,8 +274,8 @@ function language_configuration_element_submit(&$form, &$form_state) { // Iterate through all the language_configuration elements and save their // values. if (isset($form['#language_configuration_elements'])) { - foreach ($form['#language_configuration_elements'] as $element_name => $entity_type) { - language_save_configuration($entity_type, $form_state['values'][$element_name]); + foreach ($form['#language_configuration_elements'] as $element_name => $values) { + language_save_configuration($values['entity_type'], $values['bundle'], $form_state['values'][$element_name]); } } } @@ -283,35 +283,37 @@ function language_configuration_element_submit(&$form, &$form_state) { /** * Saves a language configuration that is attached to a bundle or entity type. * - * @param array $entity_type - * An array that contains information about the entity type (and bundle) for - * which the settings are saved. It can have the following keys: - * - entity_type: the type of the entity - * - bundle: if the setting is attached to a bundle of an entity type, then - * this should be specified by this value. + * @param string $entity_type + * A string representing the entity type. + * + * @param string $bundle + * A string representing the bundle. * * @param array $values * An array with values to be saved. It has the following keys: * - language: the language code. * - language_hidden: if the language element should be hidden or not. */ -function language_save_configuration($entity_type, $values) { - config('language.settings')->set(language_get_configuration_settings_path($entity_type), array('language' => $values['language'], 'language_hidden' => $values['language_hidden']))->save(); +function language_save_configuration($entity_type, $bundle, $values = array()) { + config('language.settings')->set(language_get_configuration_settings_path($entity_type, $bundle), array('language' => $values['language'], 'language_hidden' => $values['language_hidden']))->save(); } /** * Returns the language configuration stored for an entity type (and bundle). * - * @param array $entity_type - * An array with the same structure as in language_save_configuration(). + * @param string $entity_type + * A string representing the entity type. + * + * @param string $bundle + * A string representing the bundle. * * @return array * An array with the following keys: * - language: the language code. * - language_hidden: if the language element is hidden or not. */ -function language_get_configuration($entity_type) { - return config('language.settings')->get(language_get_configuration_settings_path($entity_type)); +function language_get_configuration($entity_type, $bundle) { + return config('language.settings')->get(language_get_configuration_settings_path($entity_type, $bundle)); } /** @@ -320,21 +322,17 @@ function language_get_configuration($entity_type) { * Based on the entity type (and if needed, bundle), the variables used to store * the configuration will have a common root name. * - * @param array $entity_type - * An array with the same structure as in language_save_configuration(). + * @param string $entity_type + * A string representing the entity type. + * + * @param string $bundle + * A string representing the bundle. * * @return string * The root name of the variables. */ -function language_get_configuration_settings_path($entity_type) { - $root_name = 'language_configuration'; - if (isset($entity_type['entity_type'])) { - $root_name .= '.' . $entity_type['entity_type']; - } - if (isset($entity_type['bundle'])) { - $root_name .= '.' . $entity_type['bundle']; - } - return $root_name; +function language_get_configuration_settings_path($entity_type, $bundle) { + return 'language_configuration.' . $entity_type . '.' . $bundle; } /** diff --git a/core/modules/language/tests/language_elements_test/language_elements_test.module b/core/modules/language/tests/language_elements_test/language_elements_test.module index 428f14b..b7fdec3 100644 --- a/core/modules/language/tests/language_elements_test/language_elements_test.module +++ b/core/modules/language/tests/language_elements_test/language_elements_test.module @@ -21,7 +21,7 @@ function language_elements_test_menu() { function language_elements_test_configuration_element() { //$form['#submit'] = array('_language_elements_test_submit_values_json'); - $conf = language_get_configuration(array('entity_type' => 'some_custom_type', 'bundle' => 'some_bundle')); + $conf = language_get_configuration('some_custom_type', 'some_bundle'); $form['lang_configuration'] = array( '#type' => 'language_configuration',