diff --git a/core/modules/taxonomy/lib/Drupal/taxonomy/TermFormController.php b/core/modules/taxonomy/lib/Drupal/taxonomy/TermFormController.php index a8a879b..ce3479d 100644 --- a/core/modules/taxonomy/lib/Drupal/taxonomy/TermFormController.php +++ b/core/modules/taxonomy/lib/Drupal/taxonomy/TermFormController.php @@ -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', 'vocabulary', $vocabulary->id()); $form['langcode'] = array( '#type' => 'language_select', '#title' => t('Language'), diff --git a/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/TermLanguageTest.php b/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/TermLanguageTest.php index 7cff108..df08a97 100644 --- a/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/TermLanguageTest.php +++ b/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/TermLanguageTest.php @@ -49,7 +49,7 @@ function testTermLanguage() { $edit = array( 'default_language[language_hidden]' => FALSE, ); - $this->drupalPost('admin/structure/taxonomy/' . $this->vocabulary->machine_name . '/edit', $edit, t('Save')); + $this->drupalPost('admin/structure/taxonomy/' . $this->vocabulary->id() . '/edit', $edit, t('Save')); // Add a term. $this->drupalGet('admin/structure/taxonomy/' . $this->vocabulary->id() . '/add'); @@ -85,8 +85,8 @@ function testDefaultTermLanguage() { 'default_language[langcode]' => 'bb', 'default_language[language_hidden]' => FALSE, ); - $this->drupalPost('admin/structure/taxonomy/' . $this->vocabulary->machine_name . '/edit', $edit, t('Save')); - $this->drupalGet('admin/structure/taxonomy/' . $this->vocabulary->machine_name . '/add'); + $this->drupalPost('admin/structure/taxonomy/' . $this->vocabulary->id() . '/edit', $edit, t('Save')); + $this->drupalGet('admin/structure/taxonomy/' . $this->vocabulary->id() . '/add'); $this->assertOptionSelected('edit-langcode', 'bb'); // Make the default language of the terms to be the current interface. @@ -94,10 +94,10 @@ function testDefaultTermLanguage() { 'default_language[langcode]' => 'current_interface', 'default_language[language_hidden]' => FALSE, ); - $this->drupalPost('admin/structure/taxonomy/' . $this->vocabulary->machine_name . '/edit', $edit, t('Save')); - $this->drupalGet('aa/admin/structure/taxonomy/' . $this->vocabulary->machine_name . '/add'); + $this->drupalPost('admin/structure/taxonomy/' . $this->vocabulary->id() . '/edit', $edit, t('Save')); + $this->drupalGet('aa/admin/structure/taxonomy/' . $this->vocabulary->id() . '/add'); $this->assertOptionSelected('edit-langcode', 'aa'); - $this->drupalGet('bb/admin/structure/taxonomy/' . $this->vocabulary->machine_name . '/add'); + $this->drupalGet('bb/admin/structure/taxonomy/' . $this->vocabulary->id() . '/add'); $this->assertOptionSelected('edit-langcode', 'bb'); // Change the default language of the site and check if the default terms @@ -112,8 +112,8 @@ function testDefaultTermLanguage() { 'default_language[langcode]' => 'site_default', 'default_language[language_hidden]' => FALSE, ); - $this->drupalPost('admin/structure/taxonomy/' . $this->vocabulary->machine_name . '/edit', $edit, t('Save')); - $this->drupalGet('admin/structure/taxonomy/' . $this->vocabulary->machine_name . '/add'); + $this->drupalPost('admin/structure/taxonomy/' . $this->vocabulary->id() . '/edit', $edit, t('Save')); + $this->drupalGet('admin/structure/taxonomy/' . $this->vocabulary->id() . '/add'); $this->assertOptionSelected('edit-langcode', 'cc'); } } diff --git a/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/VocabularyLanguageTest.php b/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/VocabularyLanguageTest.php index 7b70f97..5ece4f1 100644 --- a/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/VocabularyLanguageTest.php +++ b/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/VocabularyLanguageTest.php @@ -52,7 +52,7 @@ function testVocabularyLanguage() { $this->drupalGet('admin/structure/taxonomy/add'); // Check that we have the language selector available. - $this->assertField('edit-langcode', t('The language selector field was found on the page')); + $this->assertField('edit-langcode', 'The language selector field was found on the page'); // Create the vocabulary. $vid = drupal_strtolower($this->randomName()); @@ -64,7 +64,7 @@ function testVocabularyLanguage() { // Check the language on the edit page. $this->drupalGet('admin/structure/taxonomy/' . $vid . '/edit'); - $this->assertOptionSelected('edit-langcode', $edit['langcode'], t('The vocabulary language was correctly selected.')); + $this->assertOptionSelected('edit-langcode', $edit['langcode'], 'The vocabulary language was correctly selected.'); // Change the language and save again. $edit['langcode'] = 'bb'; @@ -73,7 +73,7 @@ function testVocabularyLanguage() { // Check again the language on the edit page. $this->drupalGet('admin/structure/taxonomy/' . $vid . '/edit'); - $this->assertOptionSelected('edit-langcode', $edit['langcode'], t('The vocabulary language was correctly selected.')); + $this->assertOptionSelected('edit-langcode', $edit['langcode'], 'The vocabulary language was correctly selected.'); } /** @@ -84,19 +84,19 @@ function testVocabularyDefaultLanguageForTerms() { // the terms are saved. $edit = array( 'name' => $this->randomName(), - 'machine_name' => drupal_strtolower($this->randomName()), + 'vid' => drupal_strtolower($this->randomName()), 'default_language[langcode]' => 'bb', 'default_language[language_hidden]' => FALSE, ); - $machine_name = $edit['machine_name']; + $vid = $edit['vid']; $this->drupalPost('admin/structure/taxonomy/add', $edit, t('Save')); // Check that the vocabulary was actually created. - $this->drupalGet('admin/structure/taxonomy/' . $edit['machine_name'] . '/edit'); + $this->drupalGet('admin/structure/taxonomy/' . $edit['vid'] . '/edit'); $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('vocabulary', $edit['vid']); $this->assertEqual($language_settings['langcode'], 'bb'); $this->assertEqual($language_settings['language_hidden'], FALSE); @@ -109,32 +109,27 @@ function testVocabularyDefaultLanguageForTerms() { 'default_language[langcode]' => 'aa', 'default_language[language_hidden]' => TRUE, ); - $this->drupalPost('admin/structure/taxonomy/' . $machine_name . '/edit', $edit, t('Save')); + $this->drupalPost('admin/structure/taxonomy/' . $vid . '/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('vocabulary', $vid); $this->assertEqual($language_settings['langcode'], 'aa'); $this->assertEqual($language_settings['language_hidden'], TRUE); - $this->drupalGet('admin/structure/taxonomy/' . $machine_name . '/edit'); + $this->drupalGet('admin/structure/taxonomy/' . $vid . '/edit'); $this->assertOptionSelected('edit-default-language-langcode', 'aa', 'The correct default language for the terms of this vocabulary is selected.'); $this->assertFieldChecked('edit-default-language-language-hidden', 'Hide language selection option is not checked.'); - // Check that, if the machine name of the vocabulary is changed, then the - // settings are applied on the new machine name. - $edit = array( - 'machine_name' => $machine_name . '_new', + // Check that language settings are changed after editing vocabulary. + $edit = array( + 'name' => $this->randomName(), 'default_language[langcode]' => 'authors_default', 'default_language[language_hidden]' => TRUE, ); - $new_machine_name = $edit['machine_name']; - $this->drupalPost('admin/structure/taxonomy/' . $machine_name . '/edit', $edit, t('Save')); + $this->drupalPost('admin/structure/taxonomy/' . $vid . '/edit', $edit, t('Save')); - // Check that the old settings are empty. - $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('vocabulary', $vid); $this->assertEqual($new_settings['langcode'], 'authors_default'); $this->assertEqual($new_settings['language_hidden'], TRUE); } diff --git a/core/modules/taxonomy/lib/Drupal/taxonomy/VocabularyFormController.php b/core/modules/taxonomy/lib/Drupal/taxonomy/VocabularyFormController.php index 8c39c6e..9690b29 100644 --- a/core/modules/taxonomy/lib/Drupal/taxonomy/VocabularyFormController.php +++ b/core/modules/taxonomy/lib/Drupal/taxonomy/VocabularyFormController.php @@ -65,9 +65,9 @@ public function form(array $form, array &$form_state, EntityInterface $vocabular '#type' => 'language_configuration', '#entity_information' => array( 'entity_type' => 'vocabulary', - 'bundle' => $vocabulary->machine_name, + 'bundle' => $vocabulary->id(), ), - '#default_value' => language_get_default_configuration('vocabulary', $vocabulary->machine_name), + '#default_value' => language_get_default_configuration('vocabulary', $vocabulary->id()), ); } // Set the hierarchy to "multiple parents" by default. This simplifies the @@ -128,13 +128,13 @@ public function languageConfigurationSubmit(array &$form, array &$form_state) { $vocabulary = $this->getEntity($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); + if ($vocabulary && $vocabulary->id() && $vocabulary->id() != $form_state['values']['vid']) { + language_clear_default_configuration('vocabulary', $vocabulary->id()); } // 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 // configuration in order to have the correct bundle value. - $form_state['language']['default_language']['bundle'] = $form_state['values']['machine_name']; + $form_state['language']['default_language']['bundle'] = $form_state['values']['vid']; } /**