diff --git a/core/modules/language/language.module b/core/modules/language/language.module index 0d58e77..fd51ff4 100644 --- a/core/modules/language/language.module +++ b/core/modules/language/language.module @@ -228,33 +228,6 @@ function language_save_default_configuration($entity_type, $bundle, $values = ar } /** - * Returns the language configuration stored for an entity type and bundle. - * - * @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: - * - langcode: the language code. - * - language_alterable: if the language element is hidden or not. - * - * @deprecated in Drupal 8.0.x-dev, will be removed in Drupal 9.0.0. - * Call - * \Drupal\language\Entity\ContentLanguageSettings::loadByEntityTypeBundle - * instead. - */ -function language_get_default_configuration($entity_type, $bundle) { - $default = ['langcode' => LanguageInterface::LANGCODE_SITE_DEFAULT, 'language_alterable' => false]; - $config = ContentLanguageSettings::loadByEntityTypeBundle($entity_type, $bundle); - if ($config) { - $default = ['langcode' => $config->getDefaultLangcode(), 'language_alterable' => $config->isLanguageAlterable()]; - } - return $default; -} - -/** * Clears the default language configuration for an entity type and bundle. * * @param string $entity_type diff --git a/core/modules/language/src/Tests/LanguageConfigurationElementTest.php b/core/modules/language/src/Tests/LanguageConfigurationElementTest.php index 6a262a3..864145f 100644 --- a/core/modules/language/src/Tests/LanguageConfigurationElementTest.php +++ b/core/modules/language/src/Tests/LanguageConfigurationElementTest.php @@ -130,18 +130,20 @@ public function testNodeTypeUpdate() { ); $this->drupalPostForm('admin/structure/types/manage/article', $edit, t('Save content type')); // Check the language default configuration for the articles. - $configuration = language_get_default_configuration('node', 'article'); - $uuid = ContentLanguageSettings::loadByEntityTypeBundle('node', 'article')->uuid(); - $this->assertEqual($configuration, array('langcode' => 'current_interface', 'language_alterable' => TRUE), 'The default language configuration has been saved on the Article content type.'); + $configuration = ContentLanguageSettings::loadByEntityTypeBundle('node', 'article'); + $uuid = $configuration->uuid(); + $this->assertEqual($configuration->getDefaultLangcode(), 'current_interface', 'The default language configuration has been saved on the Article content type.'); + $this->assertEqual($configuration->isLanguageAlterable(), TRUE, 'The alterable language configuration has been saved on the Article content type.'); // Rename the article content type. $edit = array( 'type' => 'article_2' ); $this->drupalPostForm('admin/structure/types/manage/article', $edit, t('Save content type')); // Check that we still have the settings for the new node type. - $configuration = language_get_default_configuration('node', 'article_2'); - $this->assertEqual($configuration, array('langcode' => 'current_interface', 'language_alterable' => TRUE), 'The default language configuration has been kept on the new Article content type.'); - $this->assertEqual(ContentLanguageSettings::loadByEntityTypeBundle('node', 'article_2')->uuid(), $uuid, 'The language configuration uuid has been kept on the new Article content type.'); + $configuration = ContentLanguageSettings::loadByEntityTypeBundle('node', 'article_2'); + $this->assertEqual($configuration->getDefaultLangcode(), 'current_interface', 'The default language configuration has been kept on the new Article content type.'); + $this->assertEqual($configuration->isLanguageAlterable(), TRUE, 'The alterable language configuration has been kept on the new Article content type.'); + $this->assertEqual($configuration->uuid(), $uuid, 'The language configuration uuid has been kept on the new Article content type.'); } /** @@ -163,18 +165,20 @@ public function testTaxonomyVocabularyUpdate() { $this->drupalPostForm('admin/structure/taxonomy/manage/country', $edit, t('Save')); // Check the language default configuration. - $configuration = language_get_default_configuration('taxonomy_term', 'country'); - $uuid = ContentLanguageSettings::loadByEntityTypeBundle('taxonomy_term', 'country')->uuid(); - $this->assertEqual($configuration, array('langcode' => 'current_interface', 'language_alterable' => TRUE), 'The default language configuration has been saved on the Country vocabulary.'); + $configuration = ContentLanguageSettings::loadByEntityTypeBundle('taxonomy_term', 'country'); + $uuid = $configuration->uuid(); + $this->assertEqual($configuration->getDefaultLangcode(), 'current_interface', 'The default language configuration has been saved on the Country vocabulary.'); + $this->assertEqual($configuration->isLanguageAlterable(), TRUE, 'The alterable language configuration has been saved on the Country vocabulary.'); // Rename the vocabulary. $edit = array( 'vid' => 'nation' ); $this->drupalPostForm('admin/structure/taxonomy/manage/country', $edit, t('Save')); // Check that we still have the settings for the new vocabulary. - $configuration = language_get_default_configuration('taxonomy_term', 'nation'); - $this->assertEqual($configuration, array('langcode' => 'current_interface', 'language_alterable' => TRUE), 'The default language configuration has been kept on the new Country vocabulary.'); - $this->assertEqual(ContentLanguageSettings::loadByEntityTypeBundle('taxonomy_term', 'nation')->uuid(), $uuid, 'The language configuration uuid has been kept on the new Country vocabulary.'); + $configuration = ContentLanguageSettings::loadByEntityTypeBundle('taxonomy_term', 'nation'); + $this->assertEqual($configuration->getDefaultLangcode(), 'current_interface', 'The default language configuration has been kept on the new Country vocabulary.'); + $this->assertEqual($configuration->isLanguageAlterable(), TRUE, 'The alterable language configuration has been kept on the new Country vocabulary.'); + $this->assertEqual($configuration->uuid(), $uuid, 'The language configuration uuid has been kept on the new Country vocabulary.'); } } diff --git a/core/modules/system/entity.api.php b/core/modules/system/entity.api.php index cfb41c7..189e8a2 100644 --- a/core/modules/system/entity.api.php +++ b/core/modules/system/entity.api.php @@ -11,6 +11,7 @@ use Drupal\Core\Entity\DynamicallyFieldableEntityStorageInterface; use Drupal\Core\Field\BaseFieldDefinition; use Drupal\Core\Render\Element; +use Drupal\language\Entity\ContentLanguageSettings; /** * @defgroup entity_crud Entity CRUD, editing, and view hooks @@ -1911,8 +1912,8 @@ function hook_entity_extra_field_info() { // Visibility of the ordering of the language selector is the same as on the // node/add form. if ($module_language_enabled) { - $configuration = language_get_default_configuration('node', $bundle->type); - if ($configuration['language_alterable']) { + $configuration = ContentLanguageSettings::loadByEntityTypeBundle('node', $bundle->type); + if ($configuration->isLanguageAlterable()) { $extra['node'][$bundle->type]['form']['language'] = array( 'label' => t('Language'), 'description' => $description,