Commit 856e8f75 authored by catch's avatar catch

Issue #1739928 by plach: Follow up for generalizing language configuration on...

Issue #1739928 by plach: Follow up for generalizing language configuration on content types to apply to terms and other entities.
parent 10e58bdd
......@@ -41,7 +41,7 @@ public function form(array $form, array &$form_state, EntityInterface $term) {
'#format' => $term->format,
'#weight' => 0,
);
$language_configuration = module_invoke('language', 'get_default_configuration', 'vocabulary', $vocabulary->machine_name);
$language_configuration = module_invoke('language', 'get_default_configuration', 'taxonomy_term', $vocabulary->machine_name);
$form['langcode'] = array(
'#type' => 'language_select',
'#title' => t('Language'),
......
......@@ -95,7 +95,7 @@ function testVocabularyDefaultLanguageForTerms() {
$this->assertResponse(200, 'The vocabulary has been created.');
// Check that the language settings were saved.
$language_settings = language_get_default_configuration('vocabulary', $edit['machine_name']);
$language_settings = language_get_default_configuration('taxonomy_term', $edit['machine_name']);
$this->assertEqual($language_settings['langcode'], 'bb');
$this->assertEqual($language_settings['language_hidden'], FALSE);
......@@ -111,7 +111,7 @@ function testVocabularyDefaultLanguageForTerms() {
$this->drupalPost('admin/structure/taxonomy/' . $machine_name . '/edit', $edit, t('Save'));
// And check again the settings and also the interface.
$language_settings = language_get_default_configuration('vocabulary', $machine_name);
$language_settings = language_get_default_configuration('taxonomy_term', $machine_name);
$this->assertEqual($language_settings['langcode'], 'aa');
$this->assertEqual($language_settings['language_hidden'], TRUE);
......@@ -133,7 +133,7 @@ function testVocabularyDefaultLanguageForTerms() {
$old_settings = config('language.settings')->get(language_get_default_configuration_settings_key('vocabulary', $machine_name));
$this->assertNull($old_settings, 'The old vocabulary settings were deleted.');
// Check that we have the new settings.
$new_settings = language_get_default_configuration('vocabulary', $new_machine_name);
$new_settings = language_get_default_configuration('taxonomy_term', $new_machine_name);
$this->assertEqual($new_settings['langcode'], 'authors_default');
$this->assertEqual($new_settings['language_hidden'], TRUE);
}
......
......@@ -63,10 +63,10 @@ public function form(array $form, array &$form_state, EntityInterface $vocabular
$form['default_terms_language']['default_language'] = array(
'#type' => 'language_configuration',
'#entity_information' => array(
'entity_type' => 'vocabulary',
'entity_type' => 'taxonomy_term',
'bundle' => $vocabulary->machine_name,
),
'#default_value' => language_get_default_configuration('vocabulary', $vocabulary->machine_name),
'#default_value' => language_get_default_configuration('taxonomy_term', $vocabulary->machine_name),
);
}
// Set the hierarchy to "multiple parents" by default. This simplifies the
......@@ -132,7 +132,7 @@ public function languageConfigurationSubmit(array &$form, array &$form_state) {
// Delete the old language settings for the vocabulary, if the machine name
// is changed.
if ($vocabulary && isset($vocabulary->machine_name) && $vocabulary->machine_name != $form_state['values']['machine_name']) {
language_clear_default_configuration('vocabulary', $vocabulary->machine_name);
language_clear_default_configuration('taxonomy_term', $vocabulary->machine_name);
}
// Since the machine name is not known yet, and it can be changed anytime,
// we have to also update the bundle property for the default language
......
......@@ -534,7 +534,7 @@ function theme_taxonomy_overview_terms($variables) {
function taxonomy_term_add($vocabulary) {
$term = entity_create('taxonomy_term', array('vid' => $vocabulary->vid, 'vocabulary_machine_name' => $vocabulary->machine_name));
if (module_exists('language')) {
$term->langcode = language_get_default_langcode('vocabulary', $vocabulary->machine_name);
$term->langcode = language_get_default_langcode('taxonomy_term', $vocabulary->machine_name);
}
return entity_get_form($term);
}
......
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