diff --git a/core/modules/language/language.module b/core/modules/language/language.module index 5e413f0..ebdf10b 100644 --- a/core/modules/language/language.module +++ b/core/modules/language/language.module @@ -196,6 +196,10 @@ function language_configuration_element_submit(&$form, FormStateInterface $form_ * An array holding the values to be saved having the following keys: * - langcode: the language code. * - language_alterable: if the language element should be hidden or not. + * + * @deprecated in Drupal 8.0.x-dev, will be removed before Drupal 8.0.0. + * Create and save a \Drupal\language\Entity\ContentLanguageSettings config + * entity instead. */ function language_save_default_configuration($entity_type, $bundle, $values = array()) { $config = ContentLanguageSettings::loadByEntityTypeBundle($entity_type, $bundle); @@ -220,6 +224,11 @@ function language_save_default_configuration($entity_type, $bundle, $values = ar * 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 before Drupal 8.0.0. + * Call + * \Drupal\language\Entity\ContentLanguageSettings::loadByEntityTypeBundle + * instead. */ function language_get_default_configuration($entity_type, $bundle) { $config = ContentLanguageSettings::loadByEntityTypeBundle($entity_type, $bundle); @@ -233,6 +242,11 @@ function language_get_default_configuration($entity_type, $bundle) { * A string representing the entity type. * @param string $bundle * A string representing the bundle. + * + * @deprecated in Drupal 8.0.x-dev, will be removed before Drupal 8.0.0. + * Call + * \Drupal\language\Entity\ContentLanguageSettings::loadByEntityTypeBundle + * and if the returned config entity is new, delete it. */ function language_clear_default_configuration($entity_type, $bundle) { $config = ContentLanguageSettings::loadByEntityTypeBundle($entity_type, $bundle); diff --git a/core/modules/language/src/ContentLanguageSettingsInterface.php b/core/modules/language/src/ContentLanguageSettingsInterface.php new file mode 100644 index 0000000..3f1d31c --- /dev/null +++ b/core/modules/language/src/ContentLanguageSettingsInterface.php @@ -0,0 +1,87 @@ +target_entity_type_id; } /** - * Gets the bundle this config applies to. - * @return string + * {@inheritdoc} */ public function getTargetBundle() { return $this->target_bundle; } /** - * Sets the default language code. - * - * @param string $default_langcode - * - * @return $this; + * {@inheritdoc} */ public function setDefaultLangcode($default_langcode) { $this->default_langcode = $default_langcode; @@ -102,20 +95,14 @@ public function setDefaultLangcode($default_langcode) { } /** - * Gets the default language code. - * - * @return string + * {@inheritdoc} */ public function getDefaultLangcode() { return $this->default_langcode; } /** - * Sets if the language must be alterable or not. - * - * @param bool $language_alterable - * - * @return $this + * {@inheritdoc} */ public function setLanguageAlterable($language_alterable) { $this->language_alterable = $language_alterable; @@ -124,9 +111,7 @@ public function setLanguageAlterable($language_alterable) { } /** - * Checks if the language is alterable or not. - * - * @return bool + * {@inheritdoc} */ public function isLanguageAlterable() { return $this->language_alterable; @@ -143,26 +128,14 @@ public function preSave(EntityStorageInterface $storage) { } /** - * Checks if this config object contains the default values in every property. - * - * @return bool - * True if all the properties contain the default values. False otherwise. + * {@inheritdoc} */ public function isDefaultConfiguration() { return (!$this->language_alterable && $this->default_langcode == LanguageInterface::LANGCODE_SITE_DEFAULT); } /** - * Loads a content language config entity based on the entity type and bundle. - * - * @param string $entity_type_id - * ID of the entity type. - * @param string $bundle - * Bundle name. - * - * @return static - * The content language config entity if one exists. Otherwise, returns - * sensible default values. + * {@inheritdoc} */ public static function loadByEntityTypeBundle($entity_type_id, $bundle) { $config = \Drupal::entityManager()->getStorage('language_content_settings')->load($entity_type_id . '.' . $bundle); diff --git a/core/modules/language/src/Tests/LanguageConfigSchemaTest.php b/core/modules/language/src/Tests/LanguageConfigSchemaTest.php index 9fb03a8..56dd719 100644 --- a/core/modules/language/src/Tests/LanguageConfigSchemaTest.php +++ b/core/modules/language/src/Tests/LanguageConfigSchemaTest.php @@ -65,11 +65,11 @@ function testValidLanguageConfigSchema() { $this->drupalPostForm($settings_path, $edit, t('Save configuration')); - $config_data = \Drupal::config('language.content_settings.menu_link_content.menu_link_content')->get(); + $config_data = \Drupal::config('language.content_settings.menu_link_content.menu_link_content'); // Make sure configuration saved correctly. - $this->assertTrue($config_data['language_alterable']); + $this->assertTrue($config_data->get('language_alterable')); - $this->assertConfigSchema(\Drupal::service('config.typed'), 'language.content_settings.menu_link_content.menu_link_content', $config_data); + $this->assertConfigSchema(\Drupal::service('config.typed'), $config_data->getName(), $config_data->get()); } }