diff --git a/core/includes/bootstrap.inc b/core/includes/bootstrap.inc index d33d1ee..82b9cd0 100644 --- a/core/includes/bootstrap.inc +++ b/core/includes/bootstrap.inc @@ -24,7 +24,7 @@ use Symfony\Component\DependencyInjection\Exception\RuntimeException as DependencyInjectionRuntimeException; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; -use Drupal\Core\Language\Language; +use Drupal\Core\Language\LanguageInterface; use Drupal\Core\Lock\DatabaseLockBackend; use Drupal\Core\Lock\LockBackendInterface; use Drupal\Core\Session\AnonymousUserSession; @@ -1844,7 +1844,7 @@ function drupal_installation_attempted() { * @see \Drupal\Core\Language\LanguageManager * * @param string $type - * The type of language object needed, e.g. Language::TYPE_INTERFACE. + * The type of language object needed, e.g. LanguageInterface::TYPE_INTERFACE. * * @deprecated in Drupal 8.x-dev, will be removed before Drupal 8.0. * Use \Drupal::languageManager()->getCurrentLanguage(). @@ -1858,17 +1858,17 @@ function language($type) { * * @param $flags * (optional) Specifies the state of the languages that have to be returned. - * It can be: Language::STATE_CONFIGURABLE, Language::STATE_LOCKED, - * Language::STATE_ALL. + * It can be: LanguageInterface::STATE_CONFIGURABLE, + * LanguageInterface::STATE_LOCKED, or LanguageInterface::STATE_ALL. * - * @return array + * @return \Drupal\Core\Language\LanguageInterface[] * An associative array of languages, keyed by the language code, ordered by * weight ascending and name ascending. * * @deprecated in Drupal 8.x-dev, will be removed before Drupal 8.0. * Use \Drupal::languageManager()->getLanguages(). */ -function language_list($flags = Language::STATE_CONFIGURABLE) { +function language_list($flags = LanguageInterface::STATE_CONFIGURABLE) { return \Drupal::languageManager()->getLanguages($flags); } diff --git a/core/includes/common.inc b/core/includes/common.inc index f30bcdf..f4d6147 100644 --- a/core/includes/common.inc +++ b/core/includes/common.inc @@ -18,7 +18,7 @@ use Drupal\Component\Utility\Tags; use Drupal\Component\Utility\UrlHelper; use Drupal\Core\Cache\Cache; -use Drupal\Core\Language\Language; +use Drupal\Core\Language\LanguageInterface; use Drupal\Core\Site\Settings; use Symfony\Component\HttpFoundation\Response; use Symfony\Component\HttpFoundation\Request; @@ -414,7 +414,7 @@ function check_url($uri) { * Arbitrary elements may be added using the $args associative array. */ function format_rss_channel($title, $link, $description, $items, $langcode = NULL, $args = array()) { - $langcode = $langcode ? $langcode : \Drupal::languageManager()->getCurrentLanguage(Language::TYPE_CONTENT)->id; + $langcode = $langcode ? $langcode : \Drupal::languageManager()->getCurrentLanguage(LanguageInterface::TYPE_CONTENT)->getId(); $output = "\n"; $output .= ' ' . String::checkPlain($title) . "\n"; @@ -875,7 +875,7 @@ function l($text, $path, array $options = array()) { // Add a hreflang attribute if we know the language of this link's url and // hreflang has not already been set. if (!empty($variables['options']['language']) && !isset($variables['options']['attributes']['hreflang'])) { - $variables['options']['attributes']['hreflang'] = $variables['options']['language']->id; + $variables['options']['attributes']['hreflang'] = $variables['options']['language']->getId(); } // Set the "active" class if the 'set_active_class' option is not empty. @@ -1801,7 +1801,7 @@ function _drupal_add_js($data = NULL, $options = NULL) { 'currentPath' => $current_path, 'currentPathIsAdmin' => $current_path_is_admin, 'isFront' => drupal_is_front_page(), - 'currentLanguage' => \Drupal::languageManager()->getCurrentLanguage(Language::TYPE_URL)->id, + 'currentLanguage' => \Drupal::languageManager()->getCurrentLanguage(LanguageInterface::TYPE_URL)->getId(), ); if (!empty($current_query)) { ksort($current_query); diff --git a/core/includes/entity.inc b/core/includes/entity.inc index b28132b..95e0fca 100644 --- a/core/includes/entity.inc +++ b/core/includes/entity.inc @@ -8,7 +8,6 @@ use Drupal\Core\Cache\Cache; use Drupal\Core\Entity\EntityStorageException; use Drupal\Core\Entity\EntityInterface; -use Drupal\Core\Language\Language; /** * Resets the cached information about entity types. diff --git a/core/includes/form.inc b/core/includes/form.inc index 42206a4..43ae137 100644 --- a/core/includes/form.inc +++ b/core/includes/form.inc @@ -12,7 +12,6 @@ use Drupal\Component\Utility\Xss; use Drupal\Core\Database\Database; use Drupal\Core\Form\OptGroup; -use Drupal\Core\Language\Language; use Drupal\Core\Render\Element; use Drupal\Core\Template\Attribute; use Drupal\Core\Utility\Color; @@ -2027,7 +2026,7 @@ function form_process_machine_name($element, &$form_state) { 'machineName' => array( '#' . $source['#id'] => $element['#machine_name'], ), - 'langcode' => $language->id, + 'langcode' => $language->getId(), ), ); $element['#attached']['library'][] = 'core/drupal.machine-name'; diff --git a/core/includes/menu.inc b/core/includes/menu.inc index 0fefe74..9364146 100644 --- a/core/includes/menu.inc +++ b/core/includes/menu.inc @@ -7,7 +7,6 @@ use Drupal\Component\Utility\String; use Drupal\Core\Cache\Cache; -use Drupal\Core\Language\Language; use Drupal\Core\Render\Element; use Drupal\Core\Template\Attribute; use Symfony\Cmf\Component\Routing\RouteObjectInterface; diff --git a/core/includes/theme.inc b/core/includes/theme.inc index e44f13d..30aaf33 100644 --- a/core/includes/theme.inc +++ b/core/includes/theme.inc @@ -13,7 +13,6 @@ use Drupal\Component\Utility\Xss; use Drupal\Core\Config\Config; use Drupal\Core\Config\StorageException; -use Drupal\Core\Language\Language; use Drupal\Core\Extension\Extension; use Drupal\Core\Extension\ExtensionNameLengthException; use Drupal\Core\Page\FeedLinkElement; @@ -1213,7 +1212,7 @@ function template_preprocess_links(&$variables) { $link_element['#options']['set_active_class'] = TRUE; if (!empty($link['language'])) { - $li_attributes['hreflang'] = $link['language']->id; + $li_attributes['hreflang'] = $link['language']->getId(); } // Add a "data-drupal-link-query" attribute to let the @@ -2098,7 +2097,7 @@ function template_preprocess_page(&$variables) { $variables['base_path'] = base_path(); $variables['front_page'] = url(); $variables['language'] = $language_interface; - $variables['language']->dir = $language_interface->direction ? 'rtl' : 'ltr'; + $variables['language']->dir = $language_interface->getDirection() ? 'rtl' : 'ltr'; $variables['logo'] = theme_get_setting('logo.url'); $variables['site_name'] = (theme_get_setting('features.name') ? String::checkPlain($site_config->get('name')) : ''); $variables['site_slogan'] = (theme_get_setting('features.slogan') ? Xss::filterAdmin($site_config->get('slogan')) : ''); diff --git a/core/includes/update.inc b/core/includes/update.inc index 694a8a9..b54f572 100644 --- a/core/includes/update.inc +++ b/core/includes/update.inc @@ -13,6 +13,8 @@ use Drupal\Core\Config\FileStorage; use Drupal\Core\Config\ConfigException; use Drupal\Core\DrupalKernel; +use Drupal\Core\Language\Language; +use Drupal\Core\Language\LanguageInterface; use Drupal\Core\Page\DefaultHtmlPageRenderer; use Drupal\Core\Utility\Error; use Drupal\Component\Uuid\Uuid; @@ -800,14 +802,14 @@ function update_replace_permissions($replace) { * * @param $flags * (optional) Specifies the state of the languages that have to be returned. - * It can be: Language::STATE_CONFIGURABLE, Language::STATE_LOCKED, - * Language::STATE_ALL. + * It can be: LanguageInterface::STATE_CONFIGURABLE, LanguageInterface::STATE_LOCKED, + * LanguageInterface::STATE_ALL. * * @return array * An associative array of languages, keyed by the language code, ordered by * weight ascending and name ascending. */ -function update_language_list($flags = Language::STATE_CONFIGURABLE) { +function update_language_list($flags = LanguageInterface::STATE_CONFIGURABLE) { $languages = &drupal_static(__FUNCTION__); @@ -829,7 +831,7 @@ function update_language_list($flags = Language::STATE_CONFIGURABLE) { $langcode = substr($langcode_config_name, strlen('language.entity.')); $info = \Drupal::config($langcode_config_name)->get(); $languages[$langcode] = new Language(array( - 'default' => ($info['id'] == $default->id), + 'default' => ($info['id'] == $default->getId()), 'name' => $info['label'], 'id' => $info['id'], 'direction' => $info['direction'], @@ -837,13 +839,13 @@ function update_language_list($flags = Language::STATE_CONFIGURABLE) { 'weight' => $info['weight'], )); } - Language::sort($languages); + uasort($languages, '\Drupal\Core\Language\Language::sort'); } else { // No language module, so use the default language only. - $languages = array($default->id => $default); + $languages = array($default->getId() => $default); // Add the special languages, they will be filtered later if needed. - $languages += \Drupal::languageManager()->getDefaultLockedLanguages($default->weight); + $languages += \Drupal::languageManager()->getDefaultLockedLanguages($default->getWeight()); } } @@ -853,7 +855,7 @@ function update_language_list($flags = Language::STATE_CONFIGURABLE) { $filtered_languages = array(); // Add the site's default language if flagged as allowed value. - if ($flags & Language::STATE_SITE_DEFAULT) { + if ($flags & LanguageInterface::STATE_SITE_DEFAULT) { $default = isset($default) ? $default : \Drupal::languageManager()->getDefaultLanguage(); // Rename the default language. $default->name = t("Site's default language (@lang_name)", array('@lang_name' => $default->name)); @@ -861,7 +863,7 @@ function update_language_list($flags = Language::STATE_CONFIGURABLE) { } foreach ($languages as $langcode => $language) { - if (($language->locked && !($flags & Language::STATE_LOCKED)) || (!$language->locked && !($flags & Language::STATE_CONFIGURABLE))) { + if (($language->isLocked() && !($flags & LanguageInterface::STATE_LOCKED)) || (!$language->isLocked() && !($flags & LanguageInterface::STATE_CONFIGURABLE))) { continue; } $filtered_languages[$langcode] = $language; diff --git a/core/lib/Drupal.php b/core/lib/Drupal.php index 5c72435..6ea0bd0 100644 --- a/core/lib/Drupal.php +++ b/core/lib/Drupal.php @@ -461,7 +461,7 @@ public static function urlGenerator() { * displayed outside the site, such as in an RSS feed. * - 'language': An optional language object used to look up the alias * for the URL. If $options['language'] is omitted, the language will be - * obtained from \Drupal::languageManager()->getCurrentLanguage(Language::TYPE_URL). + * obtained from \Drupal::languageManager()->getCurrentLanguage(LanguageInterface::TYPE_URL). * - 'https': Whether this URL should point to a secure location. If not * defined, the current scheme is used, so the user stays on HTTP or HTTPS * respectively. if mixed mode sessions are permitted, TRUE enforces HTTPS diff --git a/core/lib/Drupal/Core/Cache/LanguageCacheContext.php b/core/lib/Drupal/Core/Cache/LanguageCacheContext.php index e2c1bd9..0a3f16c 100644 --- a/core/lib/Drupal/Core/Cache/LanguageCacheContext.php +++ b/core/lib/Drupal/Core/Cache/LanguageCacheContext.php @@ -45,7 +45,7 @@ public function getContext() { $context_parts = array(); if ($this->languageManager->isMultilingual()) { foreach ($this->languageManager->getLanguageTypes() as $type) { - $context_parts[] = $this->languageManager->getCurrentLanguage($type)->id; + $context_parts[] = $this->languageManager->getCurrentLanguage($type)->getId(); } } return implode(':', $context_parts); diff --git a/core/lib/Drupal/Core/Config/ConfigFactoryInterface.php b/core/lib/Drupal/Core/Config/ConfigFactoryInterface.php index 55eb6f6..3ea3dd4 100644 --- a/core/lib/Drupal/Core/Config/ConfigFactoryInterface.php +++ b/core/lib/Drupal/Core/Config/ConfigFactoryInterface.php @@ -7,9 +7,6 @@ namespace Drupal\Core\Config; -use Drupal\Core\Language\Language; -use Drupal\Core\Language\LanguageDefault; - /** * Defines the interface for a configuration object factory. */ diff --git a/core/lib/Drupal/Core/Config/ConfigModuleOverridesEvent.php b/core/lib/Drupal/Core/Config/ConfigModuleOverridesEvent.php index 26692ea..ced4228 100644 --- a/core/lib/Drupal/Core/Config/ConfigModuleOverridesEvent.php +++ b/core/lib/Drupal/Core/Config/ConfigModuleOverridesEvent.php @@ -8,7 +8,7 @@ namespace Drupal\Core\Config; use Drupal\Component\Utility\NestedArray; -use Drupal\Core\Language\Language; +use Drupal\Core\Language\LanguageInterface; use Symfony\Component\EventDispatcher\Event; /** @@ -42,10 +42,10 @@ class ConfigModuleOverridesEvent extends Event { * * @param array $names * A list of configuration names. - * @param \Drupal\Core\Language\Language + * @param \Drupal\Core\Language\LanguageInterface * (optional) The language for this configuration. */ - public function __construct(array $names, Language $language = NULL) { + public function __construct(array $names, LanguageInterface $language = NULL) { $this->names = $names; $this->language = $language; $this->overrides = array(); diff --git a/core/lib/Drupal/Core/Config/Entity/ConfigEntityBase.php b/core/lib/Drupal/Core/Config/Entity/ConfigEntityBase.php index 948ec6f..914e635 100644 --- a/core/lib/Drupal/Core/Config/Entity/ConfigEntityBase.php +++ b/core/lib/Drupal/Core/Config/Entity/ConfigEntityBase.php @@ -13,8 +13,8 @@ use Drupal\Core\Entity\Entity; use Drupal\Core\Config\ConfigDuplicateUUIDException; use Drupal\Core\Entity\EntityStorageInterface; -use Drupal\Core\Language\Language; use Drupal\Core\Plugin\PluginDependencyTrait; +use Drupal\Core\Language\LanguageInterface; /** * Defines a base configuration entity class. @@ -82,7 +82,7 @@ * * @var string */ - public $langcode = Language::LANGCODE_NOT_SPECIFIED; + public $langcode = LanguageInterface::LANGCODE_NOT_SPECIFIED; /** * Overrides Entity::__construct(). diff --git a/core/lib/Drupal/Core/Config/Entity/ConfigEntityInterface.php b/core/lib/Drupal/Core/Config/Entity/ConfigEntityInterface.php index 586d6df..baae80b 100644 --- a/core/lib/Drupal/Core/Config/Entity/ConfigEntityInterface.php +++ b/core/lib/Drupal/Core/Config/Entity/ConfigEntityInterface.php @@ -109,7 +109,7 @@ public function isSyncing(); * entity change is part of an uninstall process, and skip executing your code * if that is the case. * - * For example, \Drupal\language\Entity\Language::preDelete() prevents the API + * For example, \Drupal\language\Entity\LanguageInterface::preDelete() prevents the API * from deleting the default language. However during an uninstall of the * language module it is expected that the default language should be deleted. * diff --git a/core/lib/Drupal/Core/Config/Entity/ConfigEntityStorage.php b/core/lib/Drupal/Core/Config/Entity/ConfigEntityStorage.php index d23341b..cec215d 100644 --- a/core/lib/Drupal/Core/Config/Entity/ConfigEntityStorage.php +++ b/core/lib/Drupal/Core/Config/Entity/ConfigEntityStorage.php @@ -183,7 +183,7 @@ protected function doLoadMultiple(array $ids = NULL) { */ protected function doCreate(array $values) { // Set default language to site default if not provided. - $values += array('langcode' => $this->languageManager->getDefaultLanguage()->id); + $values += array('langcode' => $this->languageManager->getDefaultLanguage()->getId()); $entity = new $this->entityClass($values, $this->entityTypeId); // Default status to enabled. diff --git a/core/lib/Drupal/Core/Datetime/Date.php b/core/lib/Drupal/Core/Datetime/Date.php index 2dd512a..d141042 100644 --- a/core/lib/Drupal/Core/Datetime/Date.php +++ b/core/lib/Drupal/Core/Datetime/Date.php @@ -132,7 +132,7 @@ public function format($timestamp, $type = 'medium', $format = '', $timezone = N } if (empty($langcode)) { - $langcode = $this->languageManager->getCurrentLanguage()->id; + $langcode = $this->languageManager->getCurrentLanguage()->getId(); } // Create a DrupalDateTime object from the timestamp and timezone. diff --git a/core/lib/Drupal/Core/Datetime/DrupalDateTime.php b/core/lib/Drupal/Core/Datetime/DrupalDateTime.php index 2d4be46..7dd09d1 100644 --- a/core/lib/Drupal/Core/Datetime/DrupalDateTime.php +++ b/core/lib/Drupal/Core/Datetime/DrupalDateTime.php @@ -7,7 +7,6 @@ namespace Drupal\Core\Datetime; use Drupal\Component\Datetime\DateTimePlus; -use Drupal\Core\Language\Language; /** * Extends DateTimePlus(). @@ -53,7 +52,7 @@ class DrupalDateTime extends DateTimePlus { public function __construct($time = 'now', $timezone = NULL, $settings = array()) { // We can set the langcode and country using Drupal values. if (!isset($settings['langcode'])) { - $settings['langcode'] = \Drupal::languageManager()->getCurrentLanguage()->id; + $settings['langcode'] = \Drupal::languageManager()->getCurrentLanguage()->getId(); } if (!isset($settings['country'])) { diff --git a/core/lib/Drupal/Core/Entity/ContentEntityBase.php b/core/lib/Drupal/Core/Entity/ContentEntityBase.php index 1895cfd..2fed616 100644 --- a/core/lib/Drupal/Core/Entity/ContentEntityBase.php +++ b/core/lib/Drupal/Core/Entity/ContentEntityBase.php @@ -10,7 +10,7 @@ use Drupal\Component\Utility\String; use Drupal\Core\Entity\Plugin\DataType\EntityReference; use Drupal\Core\Entity\TypedData\EntityDataDefinition; -use Drupal\Core\Language\Language; +use Drupal\Core\Language\LanguageInterface; use Drupal\Core\Session\AccountInterface; use Drupal\Core\TypedData\TypedDataInterface; @@ -38,7 +38,7 @@ * The plain data values of the contained fields. * * This always holds the original, unchanged values of the entity. The values - * are keyed by language code, whereas Language::LANGCODE_DEFAULT is used for + * are keyed by language code, whereas LanguageInterface::LANGCODE_DEFAULT is used for * values in default language. * * @todo: Add methods for getting original fields and for determining @@ -80,7 +80,7 @@ * * @var string */ - protected $activeLangcode = Language::LANGCODE_DEFAULT; + protected $activeLangcode = LanguageInterface::LANGCODE_DEFAULT; /** * Local cache for the default language code. @@ -141,22 +141,22 @@ public function __construct(array $values, $entity_type, $bundle = FALSE, $translations = array()) { $this->entityTypeId = $entity_type; $this->entityKeys['bundle'] = $bundle ? $bundle : $this->entityTypeId; - $this->languages = $this->languageManager()->getLanguages(Language::STATE_ALL); + $this->languages = $this->languageManager()->getLanguages(LanguageInterface::STATE_ALL); foreach ($values as $key => $value) { // If the key matches an existing property set the value to the property // to set properties like isDefaultRevision. // @todo: Should this be converted somehow? - if (property_exists($this, $key) && isset($value[Language::LANGCODE_DEFAULT])) { - $this->$key = $value[Language::LANGCODE_DEFAULT]; + if (property_exists($this, $key) && isset($value[LanguageInterface::LANGCODE_DEFAULT])) { + $this->$key = $value[LanguageInterface::LANGCODE_DEFAULT]; } } $this->values = $values; foreach ($this->getEntityType()->getKeys() as $key => $field_name) { if (isset($this->values[$field_name])) { - if (is_array($this->values[$field_name]) && isset($this->values[$field_name][Language::LANGCODE_DEFAULT])) { - $this->entityKeys[$key] = $this->values[$field_name][Language::LANGCODE_DEFAULT]; + if (is_array($this->values[$field_name]) && isset($this->values[$field_name][LanguageInterface::LANGCODE_DEFAULT])) { + $this->entityKeys[$key] = $this->values[$field_name][LanguageInterface::LANGCODE_DEFAULT]; } } } @@ -164,11 +164,11 @@ public function __construct(array $values, $entity_type, $bundle = FALSE, $trans // Initialize translations. Ensure we have at least an entry for the default // language. $data = array('status' => static::TRANSLATION_EXISTING); - $this->translations[Language::LANGCODE_DEFAULT] = $data; + $this->translations[LanguageInterface::LANGCODE_DEFAULT] = $data; $this->setDefaultLangcode(); if ($translations) { foreach ($translations as $langcode) { - if ($langcode != $this->defaultLangcode && $langcode != Language::LANGCODE_DEFAULT) { + if ($langcode != $this->defaultLangcode && $langcode != LanguageInterface::LANGCODE_DEFAULT) { $this->translations[$langcode] = $data; } } @@ -427,14 +427,14 @@ protected function getTranslatedField($name, $langcode) { throw new \InvalidArgumentException('Field ' . String::checkPlain($name) . ' is unknown.'); } // Non-translatable fields are always stored with - // Language::LANGCODE_DEFAULT as key. + // LanguageInterface::LANGCODE_DEFAULT as key. - $default = $langcode == Language::LANGCODE_DEFAULT; + $default = $langcode == LanguageInterface::LANGCODE_DEFAULT; if (!$default && !$definition->isTranslatable()) { - if (!isset($this->fields[$name][Language::LANGCODE_DEFAULT])) { - $this->fields[$name][Language::LANGCODE_DEFAULT] = $this->getTranslatedField($name, Language::LANGCODE_DEFAULT); + if (!isset($this->fields[$name][LanguageInterface::LANGCODE_DEFAULT])) { + $this->fields[$name][LanguageInterface::LANGCODE_DEFAULT] = $this->getTranslatedField($name, LanguageInterface::LANGCODE_DEFAULT); } - $this->fields[$name][$langcode] = &$this->fields[$name][Language::LANGCODE_DEFAULT]; + $this->fields[$name][$langcode] = &$this->fields[$name][LanguageInterface::LANGCODE_DEFAULT]; } else { $value = NULL; @@ -446,7 +446,7 @@ protected function getTranslatedField($name, $langcode) { // $this->defaultLangcode might not be set if we are initializing the // default language code cache, in which case there is no valid // langcode to assign. - $field_langcode = isset($this->defaultLangcode) ? $this->defaultLangcode : Language::LANGCODE_NOT_SPECIFIED; + $field_langcode = isset($this->defaultLangcode) ? $this->defaultLangcode : LanguageInterface::LANGCODE_NOT_SPECIFIED; } else { $field_langcode = $langcode; @@ -554,9 +554,9 @@ public function access($operation, AccountInterface $account = NULL) { */ public function language() { $language = NULL; - if ($this->activeLangcode != Language::LANGCODE_DEFAULT) { + if ($this->activeLangcode != LanguageInterface::LANGCODE_DEFAULT) { if (!isset($this->languages[$this->activeLangcode])) { - $this->languages += $this->languageManager()->getLanguages(Language::STATE_ALL); + $this->languages += $this->languageManager()->getLanguages(LanguageInterface::STATE_ALL); } $language = $this->languages[$this->activeLangcode]; } @@ -572,16 +572,16 @@ public function language() { protected function setDefaultLangcode() { // Get the language code if the property exists. if ($this->hasField('langcode') && ($item = $this->get('langcode')) && isset($item->language)) { - $this->defaultLangcode = $item->language->id; + $this->defaultLangcode = $item->language->getId(); } if (empty($this->defaultLangcode)) { // Make sure we return a proper language object. - $this->defaultLangcode = Language::LANGCODE_NOT_SPECIFIED; + $this->defaultLangcode = LanguageInterface::LANGCODE_NOT_SPECIFIED; } // This needs to be initialized manually as it is skipped when instantiating // the language field object to avoid infinite recursion. if (!empty($this->fields['langcode'])) { - $this->fields['langcode'][Language::LANGCODE_DEFAULT]->setLangcode($this->defaultLangcode); + $this->fields['langcode'][LanguageInterface::LANGCODE_DEFAULT]->setLangcode($this->defaultLangcode); } } @@ -593,8 +593,8 @@ protected function setDefaultLangcode() { */ protected function updateFieldLangcodes($langcode) { foreach ($this->fields as $name => $items) { - if (!empty($items[Language::LANGCODE_DEFAULT])) { - $items[Language::LANGCODE_DEFAULT]->setLangcode($langcode); + if (!empty($items[LanguageInterface::LANGCODE_DEFAULT])) { + $items[LanguageInterface::LANGCODE_DEFAULT]->setLangcode($langcode); } } } @@ -630,8 +630,8 @@ public function onChange($name) { public function getTranslation($langcode) { // Ensure we always use the default language code when dealing with the // original entity language. - if ($langcode != Language::LANGCODE_DEFAULT && $langcode == $this->defaultLangcode) { - $langcode = Language::LANGCODE_DEFAULT; + if ($langcode != LanguageInterface::LANGCODE_DEFAULT && $langcode == $this->defaultLangcode) { + $langcode = LanguageInterface::LANGCODE_DEFAULT; } // Populate entity translation object cache so it will be available for all @@ -674,7 +674,7 @@ public function getTranslation($langcode) { * {@inheritdoc} */ public function getUntranslated() { - return $this->getTranslation(Language::LANGCODE_DEFAULT); + return $this->getTranslation(LanguageInterface::LANGCODE_DEFAULT); } /** @@ -721,7 +721,7 @@ protected function initializeTranslation($langcode) { */ public function hasTranslation($langcode) { if ($langcode == $this->defaultLangcode) { - $langcode = Language::LANGCODE_DEFAULT; + $langcode = LanguageInterface::LANGCODE_DEFAULT; } return !empty($this->translations[$langcode]['status']); } @@ -766,7 +766,7 @@ public function addTranslation($langcode, array $values = array()) { * {@inheritdoc} */ public function removeTranslation($langcode) { - if (isset($this->translations[$langcode]) && $langcode != Language::LANGCODE_DEFAULT && $langcode != $this->defaultLangcode) { + if (isset($this->translations[$langcode]) && $langcode != LanguageInterface::LANGCODE_DEFAULT && $langcode != $this->defaultLangcode) { foreach ($this->getFieldDefinitions() as $name => $definition) { if ($definition->isTranslatable()) { unset($this->values[$name][$langcode]); @@ -785,7 +785,7 @@ public function removeTranslation($langcode) { * {@inheritdoc} */ public function initTranslation($langcode) { - if ($langcode != Language::LANGCODE_DEFAULT && $langcode != $this->defaultLangcode) { + if ($langcode != LanguageInterface::LANGCODE_DEFAULT && $langcode != $this->defaultLangcode) { $this->translations[$langcode]['status'] = static::TRANSLATION_EXISTING; } } @@ -795,7 +795,7 @@ public function initTranslation($langcode) { */ public function getTranslationLanguages($include_default = TRUE) { $translations = array_filter($this->translations, function($translation) { return $translation['status']; }); - unset($translations[Language::LANGCODE_DEFAULT]); + unset($translations[LanguageInterface::LANGCODE_DEFAULT]); if ($include_default) { $translations[$this->defaultLangcode] = TRUE; @@ -957,7 +957,7 @@ public function __clone() { // we retain just the original value, as references will be recreated // later as needed. if (!$definitions[$name]->isTranslatable() && count($values) > 1) { - $values = array_intersect_key($values, array(Language::LANGCODE_DEFAULT => TRUE)); + $values = array_intersect_key($values, array(LanguageInterface::LANGCODE_DEFAULT => TRUE)); } foreach ($values as $langcode => $items) { $this->fields[$name][$langcode] = clone $items; diff --git a/core/lib/Drupal/Core/Entity/ContentEntityDatabaseStorage.php b/core/lib/Drupal/Core/Entity/ContentEntityDatabaseStorage.php index da6890e..b4a8135 100644 --- a/core/lib/Drupal/Core/Entity/ContentEntityDatabaseStorage.php +++ b/core/lib/Drupal/Core/Entity/ContentEntityDatabaseStorage.php @@ -11,6 +11,7 @@ use Drupal\Core\Entity\Query\QueryInterface; use Drupal\Core\Field\FieldStorageDefinitionInterface; use Drupal\Core\Language\Language; +use Drupal\Core\Language\LanguageInterface; use Drupal\field\FieldConfigUpdateForbiddenException; use Drupal\field\FieldConfigInterface; use Drupal\field\FieldInstanceConfigInterface; @@ -163,12 +164,12 @@ protected function mapFromStorageRecords(array $records) { // that store several properties). if ($field_name = strstr($name, '__', TRUE)) { $property_name = substr($name, strpos($name, '__') + 2); - $entities[$id][$field_name][Language::LANGCODE_DEFAULT][$property_name] = $value; + $entities[$id][$field_name][LanguageInterface::LANGCODE_DEFAULT][$property_name] = $value; } else { // Handle columns named directly after the field (e.g if the field // type only stores one property). - $entities[$id][$name][Language::LANGCODE_DEFAULT] = $value; + $entities[$id][$name][LanguageInterface::LANGCODE_DEFAULT] = $value; } } // If we have no multilingual values we can instantiate entity objecs @@ -209,7 +210,7 @@ protected function attachPropertyData(array &$entities) { // Get the revision IDs. $revision_ids = array(); foreach ($entities as $values) { - $revision_ids[] = is_object($values) ? $values->getRevisionId() : $values[$this->revisionKey][Language::LANGCODE_DEFAULT]; + $revision_ids[] = is_object($values) ? $values->getRevisionId() : $values[$this->revisionKey][LanguageInterface::LANGCODE_DEFAULT]; } $query->condition($this->revisionKey, $revision_ids); } @@ -228,8 +229,8 @@ protected function attachPropertyData(array &$entities) { $id = $values[$this->idKey]; // Field values in default language are stored with - // Language::LANGCODE_DEFAULT as key. - $langcode = empty($values['default_langcode']) ? $values['langcode'] : Language::LANGCODE_DEFAULT; + // LanguageInterface::LANGCODE_DEFAULT as key. + $langcode = empty($values['default_langcode']) ? $values['langcode'] : LanguageInterface::LANGCODE_DEFAULT; $translations[$id][$langcode] = TRUE; foreach (array_keys($field_definitions) as $field_name) { @@ -255,7 +256,7 @@ protected function attachPropertyData(array &$entities) { } foreach ($entities as $id => $values) { - $bundle = $this->bundleKey ? $values[$this->bundleKey][Language::LANGCODE_DEFAULT] : FALSE; + $bundle = $this->bundleKey ? $values[$this->bundleKey][LanguageInterface::LANGCODE_DEFAULT] : FALSE; // Turn the record into an entity class. $entities[$id] = new $this->entityClass($values, $this->entityTypeId, $bundle, array_keys($translations[$id])); } @@ -650,9 +651,10 @@ protected function mapToStorageRecord(EntityInterface $entity, $table_key = 'bas * The record to store. */ protected function mapToDataStorageRecord(EntityInterface $entity, $table_key = 'data_table') { + /** @var \Drupal\Core\Entity\ContentEntityInterface $entity */ $record = $this->mapToStorageRecord($entity, $table_key); - $record->langcode = $entity->language()->id; - $record->default_langcode = intval($record->langcode == $entity->getUntranslated()->language()->id); + $record->langcode = $entity->language()->getId(); + $record->default_langcode = intval($record->langcode == $entity->getUntranslated()->language()->getId()); return $record; } @@ -700,6 +702,7 @@ public function getQueryServiceName() { * {@inheritdoc} */ protected function doLoadFieldItems($entities, $age) { + /** @var \Drupal\Core\Entity\ContentEntityInterface[] $entities */ $load_current = $age == static::FIELD_LOAD_CURRENT; // Collect entities ids, bundles and languages. @@ -709,7 +712,7 @@ protected function doLoadFieldItems($entities, $age) { foreach ($entities as $key => $entity) { $bundles[$entity->bundle()] = TRUE; $ids[] = $load_current ? $key : $entity->getRevisionId(); - $default_langcodes[$key] = $entity->getUntranslated()->language()->id; + $default_langcodes[$key] = $entity->getUntranslated()->language()->getId(); } // Collect impacted fields. @@ -723,7 +726,7 @@ protected function doLoadFieldItems($entities, $age) { } // Load field data. - $langcodes = array_keys(language_list(Language::STATE_ALL)); + $langcodes = array_keys(language_list(LanguageInterface::STATE_ALL)); foreach ($fields as $field_name => $field) { $table = $load_current ? static::_fieldTableName($field) : static::_fieldRevisionTableName($field); @@ -771,11 +774,12 @@ protected function doLoadFieldItems($entities, $age) { * {@inheritdoc} */ protected function doSaveFieldItems(EntityInterface $entity, $update) { + /** @var \Drupal\Core\Entity\ContentEntityInterface $entity */ $vid = $entity->getRevisionId(); $id = $entity->id(); $bundle = $entity->bundle(); $entity_type = $entity->getEntityTypeId(); - $default_langcode = $entity->getUntranslated()->language()->id; + $default_langcode = $entity->getUntranslated()->language()->getId(); $translation_langcodes = array_keys($entity->getTranslationLanguages()); if (!isset($vid)) { diff --git a/core/lib/Drupal/Core/Entity/ContentEntityForm.php b/core/lib/Drupal/Core/Entity/ContentEntityForm.php index 8722a9c..aa003d6 100644 --- a/core/lib/Drupal/Core/Entity/ContentEntityForm.php +++ b/core/lib/Drupal/Core/Entity/ContentEntityForm.php @@ -90,7 +90,7 @@ public function getFormLangcode(array &$form_state) { // Imply a 'view' operation to ensure users edit entities in the same // language they are displayed. This allows to keep contextual editing // working also for multilingual entities. - $form_state['langcode'] = $this->entityManager->getTranslationFromContext($this->entity)->language()->id; + $form_state['langcode'] = $this->entityManager->getTranslationFromContext($this->entity)->language()->getId(); } return $form_state['langcode']; } @@ -99,7 +99,7 @@ public function getFormLangcode(array &$form_state) { * {@inheritdoc} */ public function isDefaultFormLangcode(array $form_state) { - return $this->getFormLangcode($form_state) == $this->entity->getUntranslated()->language()->id; + return $this->getFormLangcode($form_state) == $this->entity->getUntranslated()->language()->getId(); } /** diff --git a/core/lib/Drupal/Core/Entity/Entity.php b/core/lib/Drupal/Core/Entity/Entity.php index a3f1ef7..fc99cce 100644 --- a/core/lib/Drupal/Core/Entity/Entity.php +++ b/core/lib/Drupal/Core/Entity/Entity.php @@ -15,6 +15,7 @@ use Drupal\Core\Config\Entity\Exception\ConfigEntityIdLengthException; use Drupal\Core\Entity\Exception\UndefinedLinkTemplateException; use Drupal\Core\Language\Language; +use Drupal\Core\Language\LanguageInterface; use Drupal\Core\Session\AccountInterface; use Drupal\Core\Url; @@ -281,7 +282,7 @@ public function access($operation, AccountInterface $account = NULL) { } return $this->entityManager() ->getAccessController($this->entityTypeId) - ->access($this, $operation, Language::LANGCODE_DEFAULT, $account); + ->access($this, $operation, LanguageInterface::LANGCODE_DEFAULT, $account); } /** @@ -291,7 +292,7 @@ public function language() { $language = $this->languageManager()->getLanguage($this->langcode); if (!$language) { // Make sure we return a proper language object. - $language = new Language(array('id' => Language::LANGCODE_NOT_SPECIFIED)); + $language = new Language(array('id' => LanguageInterface::LANGCODE_NOT_SPECIFIED)); } return $language; } diff --git a/core/lib/Drupal/Core/Entity/EntityAccessController.php b/core/lib/Drupal/Core/Entity/EntityAccessController.php index b092914..f20ef9c 100644 --- a/core/lib/Drupal/Core/Entity/EntityAccessController.php +++ b/core/lib/Drupal/Core/Entity/EntityAccessController.php @@ -11,7 +11,7 @@ use Drupal\Core\Field\FieldItemListInterface; use Drupal\Core\Extension\ModuleHandlerInterface; use Drupal\Core\Field\FieldDefinitionInterface; -use Drupal\Core\Language\Language; +use Drupal\Core\Language\LanguageInterface; use Drupal\Core\Session\AccountInterface; /** @@ -54,7 +54,7 @@ public function __construct(EntityTypeInterface $entity_type) { /** * {@inheritdoc} */ - public function access(EntityInterface $entity, $operation, $langcode = Language::LANGCODE_DEFAULT, AccountInterface $account = NULL) { + public function access(EntityInterface $entity, $operation, $langcode = LanguageInterface::LANGCODE_DEFAULT, AccountInterface $account = NULL) { $account = $this->prepareUser($account); if (($access = $this->getCache($entity->uuid(), $operation, $langcode, $account)) !== NULL) { @@ -203,7 +203,7 @@ public function resetCache() { public function createAccess($entity_bundle = NULL, AccountInterface $account = NULL, array $context = array()) { $account = $this->prepareUser($account); $context += array( - 'langcode' => Language::LANGCODE_DEFAULT, + 'langcode' => LanguageInterface::LANGCODE_DEFAULT, ); $cid = $entity_bundle ? 'create:' . $entity_bundle : 'create'; diff --git a/core/lib/Drupal/Core/Entity/EntityAccessControllerInterface.php b/core/lib/Drupal/Core/Entity/EntityAccessControllerInterface.php index 6bc8a23..62bba90 100644 --- a/core/lib/Drupal/Core/Entity/EntityAccessControllerInterface.php +++ b/core/lib/Drupal/Core/Entity/EntityAccessControllerInterface.php @@ -10,7 +10,7 @@ use Drupal\Core\Field\FieldItemListInterface; use Drupal\Core\Extension\ModuleHandlerInterface; use Drupal\Core\Field\FieldDefinitionInterface; -use Drupal\Core\Language\Language; +use Drupal\Core\Language\LanguageInterface; use Drupal\Core\Session\AccountInterface; /** @@ -31,7 +31,7 @@ * Usually one of "view", "update" or "delete". * @param string $langcode * (optional) The language code for which to check access. Defaults to - * Language::LANGCODE_DEFAULT. + * LanguageInterface::LANGCODE_DEFAULT. * @param \Drupal\Core\Session\AccountInterface $account * (optional) The user session for which to check access, or NULL to check * access for the current user. Defaults to NULL. @@ -39,7 +39,7 @@ * @return bool * TRUE if access was granted, FALSE otherwise. */ - public function access(EntityInterface $entity, $operation, $langcode = Language::LANGCODE_DEFAULT, AccountInterface $account = NULL); + public function access(EntityInterface $entity, $operation, $langcode = LanguageInterface::LANGCODE_DEFAULT, AccountInterface $account = NULL); /** * Checks access to create an entity. diff --git a/core/lib/Drupal/Core/Entity/EntityForm.php b/core/lib/Drupal/Core/Entity/EntityForm.php index dcb9aae..7982e8b 100644 --- a/core/lib/Drupal/Core/Entity/EntityForm.php +++ b/core/lib/Drupal/Core/Entity/EntityForm.php @@ -145,7 +145,7 @@ public function form(array $form, array &$form_state) { // new entities. $form['langcode'] = array( '#type' => 'value', - '#value' => !$entity->isNew() ? $entity->language()->id : language_default()->id, + '#value' => !$entity->isNew() ? $entity->language()->getId() : language_default()->getId(), ); } return $form; @@ -287,7 +287,7 @@ public function save(array $form, array &$form_state) { * {@inheritdoc} */ public function getFormLangcode(array &$form_state) { - return $this->entity->language()->id; + return $this->entity->language()->getId(); } /** diff --git a/core/lib/Drupal/Core/Entity/EntityInterface.php b/core/lib/Drupal/Core/Entity/EntityInterface.php index ab62144..e235488 100644 --- a/core/lib/Drupal/Core/Entity/EntityInterface.php +++ b/core/lib/Drupal/Core/Entity/EntityInterface.php @@ -37,7 +37,7 @@ public function id(); /** * Returns the language of the entity. * - * @return \Drupal\Core\Language\Language + * @return \Drupal\Core\Language\LanguageInterface * The language object. */ public function language(); diff --git a/core/lib/Drupal/Core/Entity/EntityManager.php b/core/lib/Drupal/Core/Entity/EntityManager.php index 3fe2c54..0624e60 100644 --- a/core/lib/Drupal/Core/Entity/EntityManager.php +++ b/core/lib/Drupal/Core/Entity/EntityManager.php @@ -17,7 +17,7 @@ use Drupal\Core\Cache\CacheBackendInterface; use Drupal\Core\Extension\ModuleHandlerInterface; use Drupal\Core\Language\LanguageManager; -use Drupal\Core\Language\Language; +use Drupal\Core\Language\LanguageInterface; use Drupal\Core\Plugin\Discovery\AlterDecorator; use Drupal\Core\Plugin\Discovery\CacheDecorator; use Drupal\Core\Plugin\Discovery\AnnotatedClassDiscovery; @@ -173,7 +173,7 @@ public function __construct(\Traversable $namespaces, ModuleHandlerInterface $mo $this->discovery = new AnnotatedClassDiscovery('Entity', $namespaces, 'Drupal\Core\Entity\Annotation\EntityType'); $this->discovery = new InfoHookDecorator($this->discovery, 'entity_type_build'); $this->discovery = new AlterDecorator($this->discovery, 'entity_type'); - $this->discovery = new CacheDecorator($this->discovery, 'entity_type:' . $this->languageManager->getCurrentLanguage()->id, 'discovery', Cache::PERMANENT, array('entity_types' => TRUE)); + $this->discovery = new CacheDecorator($this->discovery, 'entity_type:' . $this->languageManager->getCurrentLanguage()->getId(), 'discovery', Cache::PERMANENT, array('entity_types' => TRUE)); } @@ -329,7 +329,7 @@ public function getBaseFieldDefinitions($entity_type_id) { // Check the static cache. if (!isset($this->baseFieldDefinitions[$entity_type_id])) { // Not prepared, try to load from cache. - $cid = 'entity_base_field_definitions:' . $entity_type_id . ':' . $this->languageManager->getCurrentLanguage()->id; + $cid = 'entity_base_field_definitions:' . $entity_type_id . ':' . $this->languageManager->getCurrentLanguage()->getId(); if ($cache = $this->cache->get($cid)) { $this->baseFieldDefinitions[$entity_type_id] = $cache->data; } @@ -425,7 +425,7 @@ public function getFieldDefinitions($entity_type_id, $bundle) { if (!isset($this->fieldDefinitions[$entity_type_id][$bundle])) { $base_field_definitions = $this->getBaseFieldDefinitions($entity_type_id); // Not prepared, try to load from cache. - $cid = 'entity_bundle_field_definitions:' . $entity_type_id . ':' . $bundle . ':' . $this->languageManager->getCurrentLanguage()->id; + $cid = 'entity_bundle_field_definitions:' . $entity_type_id . ':' . $bundle . ':' . $this->languageManager->getCurrentLanguage()->getId(); if ($cache = $this->cache->get($cid)) { $bundle_field_definitions = $cache->data; } @@ -517,7 +517,7 @@ public function getFieldStorageDefinitions($entity_type_id) { } } // Not prepared, try to load from cache. - $cid = 'entity_field_storage_definitions:' . $entity_type_id . ':' . $this->languageManager->getCurrentLanguage()->id; + $cid = 'entity_field_storage_definitions:' . $entity_type_id . ':' . $this->languageManager->getCurrentLanguage()->getId(); if ($cache = $this->cache->get($cid)) { $field_storage_definitions = $cache->data; } @@ -621,7 +621,7 @@ public function getBundleInfo($entity_type) { */ public function getAllBundleInfo() { if (!isset($this->bundleInfo)) { - $langcode = $this->languageManager->getCurrentLanguage()->id; + $langcode = $this->languageManager->getCurrentLanguage()->getId(); if ($cache = $this->cache->get("entity_bundle_info:$langcode")) { $this->bundleInfo = $cache->data; } @@ -662,7 +662,7 @@ public function getExtraFields($entity_type_id, $bundle) { // Read from the persistent cache. Since hook_entity_extra_field_info() and // hook_entity_extra_field_info_alter() might contain t() calls, we cache // per language. - $cache_id = 'entity_bundle_extra_fields:' . $entity_type_id . ':' . $bundle . ':' . $this->languageManager->getCurrentLanguage()->id; + $cache_id = 'entity_bundle_extra_fields:' . $entity_type_id . ':' . $bundle . ':' . $this->languageManager->getCurrentLanguage()->getId(); $cached = $this->cache->get($cache_id); if ($cached) { $this->extraFields[$entity_type_id][$bundle] = $cached->data; @@ -724,7 +724,7 @@ public function getTranslationFromContext(EntityInterface $entity, $langcode = N if ($entity instanceof TranslatableInterface) { if (empty($langcode)) { - $langcode = $this->languageManager->getCurrentLanguage(Language::TYPE_CONTENT)->id; + $langcode = $this->languageManager->getCurrentLanguage(LanguageInterface::TYPE_CONTENT)->getId(); } // Retrieve language fallback candidates to perform the entity language @@ -735,7 +735,7 @@ public function getTranslationFromContext(EntityInterface $entity, $langcode = N // Ensure the default language has the proper language code. $default_language = $entity->getUntranslated()->language(); - $candidates[$default_language->id] = Language::LANGCODE_DEFAULT; + $candidates[$default_language->getId()] = LanguageInterface::LANGCODE_DEFAULT; // Return the most fitting entity translation. foreach ($candidates as $candidate) { @@ -789,7 +789,7 @@ public function getFormModes($entity_type_id) { protected function getAllDisplayModesByEntityType($display_type) { if (!isset($this->displayModeInfo[$display_type])) { $key = 'entity_' . $display_type . '_info'; - $langcode = $this->languageManager->getCurrentLanguage(Language::TYPE_INTERFACE)->id; + $langcode = $this->languageManager->getCurrentLanguage(LanguageInterface::TYPE_INTERFACE)->getId(); if ($cache = $this->cache->get("$key:$langcode")) { $this->displayModeInfo[$display_type] = $cache->data; } diff --git a/core/lib/Drupal/Core/Entity/EntityViewBuilder.php b/core/lib/Drupal/Core/Entity/EntityViewBuilder.php index cd1cbfb..b5b05f9 100644 --- a/core/lib/Drupal/Core/Entity/EntityViewBuilder.php +++ b/core/lib/Drupal/Core/Entity/EntityViewBuilder.php @@ -13,7 +13,7 @@ use Drupal\Core\Entity\ContentEntityInterface; use Drupal\Core\Field\FieldItemInterface; use Drupal\Core\Field\FieldItemListInterface; -use Drupal\Core\Language\Language; +use Drupal\Core\Language\LanguageInterface; use Drupal\Core\Language\LanguageManagerInterface; use Drupal\Core\TypedData\TranslatableInterface; use Drupal\Core\Render\Element; @@ -109,7 +109,7 @@ public function view(EntityInterface $entity, $view_mode = 'full', $langcode = N */ public function viewMultiple(array $entities = array(), $view_mode = 'full', $langcode = NULL) { if (!isset($langcode)) { - $langcode = $this->languageManager->getCurrentLanguage(Language::TYPE_CONTENT)->id; + $langcode = $this->languageManager->getCurrentLanguage(LanguageInterface::TYPE_CONTENT)->getId(); } $build_list = array( diff --git a/core/lib/Drupal/Core/Entity/KeyValueStore/KeyValueEntityStorage.php b/core/lib/Drupal/Core/Entity/KeyValueStore/KeyValueEntityStorage.php index 442162c..30c65ca 100644 --- a/core/lib/Drupal/Core/Entity/KeyValueStore/KeyValueEntityStorage.php +++ b/core/lib/Drupal/Core/Entity/KeyValueStore/KeyValueEntityStorage.php @@ -94,7 +94,7 @@ public static function createInstance(ContainerInterface $container, EntityTypeI */ public function doCreate(array $values = array()) { // Set default language to site default if not provided. - $values += array('langcode' => $this->languageManager->getDefaultLanguage()->id); + $values += array('langcode' => $this->languageManager->getDefaultLanguage()->getId()); $entity = new $this->entityClass($values, $this->entityTypeId); // @todo This is handled by ContentEntityStorageBase, which assumes diff --git a/core/lib/Drupal/Core/EventSubscriber/FinishResponseSubscriber.php b/core/lib/Drupal/Core/EventSubscriber/FinishResponseSubscriber.php index 3063bb2..37322ec 100644 --- a/core/lib/Drupal/Core/EventSubscriber/FinishResponseSubscriber.php +++ b/core/lib/Drupal/Core/EventSubscriber/FinishResponseSubscriber.php @@ -9,7 +9,6 @@ use Drupal\Core\Config\Config; use Drupal\Core\Config\ConfigFactoryInterface; -use Drupal\Core\Language\Language; use Drupal\Core\Language\LanguageManager; use Drupal\Core\Site\Settings; use Symfony\Component\HttpFoundation\Request; @@ -70,7 +69,7 @@ public function onRespond(FilterResponseEvent $event) { $response->headers->set('X-UA-Compatible', 'IE=edge,chrome=1', FALSE); // Set the Content-language header. - $response->headers->set('Content-language', $this->languageManager->getCurrentLanguage()->id); + $response->headers->set('Content-language', $this->languageManager->getCurrentLanguage()->getId()); // Attach globally-declared headers to the response object so that Symfony // can send them for us correctly. diff --git a/core/lib/Drupal/Core/Field/FieldItemList.php b/core/lib/Drupal/Core/Field/FieldItemList.php index 39be1ee..2e0b442 100644 --- a/core/lib/Drupal/Core/Field/FieldItemList.php +++ b/core/lib/Drupal/Core/Field/FieldItemList.php @@ -11,7 +11,7 @@ use Drupal\Core\TypedData\DataDefinitionInterface; use Drupal\Core\TypedData\TypedDataInterface; use Drupal\Core\TypedData\Plugin\DataType\ItemList; -use Drupal\Core\Language\Language; +use Drupal\Core\Language\LanguageInterface; /** * Represents an entity field; that is, a list of field item objects. @@ -36,7 +36,7 @@ class FieldItemList extends ItemList implements FieldItemListInterface { * * @var string */ - protected $langcode = Language::LANGCODE_NOT_SPECIFIED; + protected $langcode = LanguageInterface::LANGCODE_NOT_SPECIFIED; /** * {@inheritdoc} diff --git a/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/LanguageItem.php b/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/LanguageItem.php index e3192b2..719a0d6 100644 --- a/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/LanguageItem.php +++ b/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/LanguageItem.php @@ -9,7 +9,7 @@ use Drupal\Core\Field\FieldStorageDefinitionInterface; use Drupal\Core\Field\FieldItemBase; -use Drupal\Core\Language\Language; +use Drupal\Core\Language\LanguageInterface; use Drupal\Core\TypedData\DataDefinition; use Drupal\Core\TypedData\DataReferenceDefinition; @@ -92,7 +92,7 @@ public function setValue($values, $notify = TRUE) { */ public function applyDefaultValue($notify = TRUE) { // Default to LANGCODE_NOT_SPECIFIED. - $this->setValue(array('value' => Language::LANGCODE_NOT_SPECIFIED), $notify); + $this->setValue(array('value' => LanguageInterface::LANGCODE_NOT_SPECIFIED), $notify); return $this; } diff --git a/core/lib/Drupal/Core/Language/Language.php b/core/lib/Drupal/Core/Language/Language.php index 4575983..c291a4e 100644 --- a/core/lib/Drupal/Core/Language/Language.php +++ b/core/lib/Drupal/Core/Language/Language.php @@ -35,14 +35,14 @@ class Language implements LanguageInterface { * * @var string */ - public $name = ''; + protected $name = ''; /** * The ID, langcode. * * @var string */ - public $id = ''; + protected $id = ''; /** * The direction, left-to-right, or right-to-left. @@ -51,21 +51,21 @@ class Language implements LanguageInterface { * * @var int */ - public $direction = self::DIRECTION_LTR; + protected $direction = self::DIRECTION_LTR; /** * The weight, used for ordering languages in lists, like selects or tables. * * @var int */ - public $weight = 0; + protected $weight = 0; /** * Flag indicating if this is the only site default language. * * @var bool */ - public $default = FALSE; + protected $default = FALSE; /** * The language negotiation method used when a language was detected. @@ -75,7 +75,7 @@ class Language implements LanguageInterface { * * @var string */ - public $method_id; + protected $negotiationMethodId; /** * Locked indicates a language used by the system, not an actual language. @@ -86,7 +86,7 @@ class Language implements LanguageInterface { * * @var bool */ - public $locked = FALSE; + protected $locked = FALSE; /** * Constructs a new class instance. @@ -197,26 +197,43 @@ public function setDefault($default) { * {@inheritdoc} */ public function getNegotiationMethodId() { - return $this->method_id; + return $this->negotiationMethodId; } /** * {@inheritdoc} */ public function setNegotiationMethodId($method_id) { - $this->method_id = $method_id; + $this->negotiationMethodId = $method_id; return $this; } /** + * {@inheritdoc} + */ + public function isLocked() { + return $this->locked; + } + + /** * Sort language objects. * - * @param array $languages - * The array of language objects keyed by langcode. + * This is a sort() callback. + * + * @param \Drupal\Core\Language\LanguageInterface $a + * @param \Drupal\Core\Language\LanguageInterface $b + * + * @return int + * -1, 0, or 1. */ - public static function sort(&$languages) { - uasort($languages, 'Drupal\Component\Utility\SortArray::sortByWeightAndTitleKey'); + public static function sort(LanguageInterface $a, LanguageInterface $b) { + if ($a->getWeight() == $b->getWeight()) { + return strnatcasecmp($a->getName(), $b->getName()); + } + else { + return $a->getWeight() < $b->getWeight() ? -1 : 1; + } } } diff --git a/core/lib/Drupal/Core/Language/LanguageDefault.php b/core/lib/Drupal/Core/Language/LanguageDefault.php index a72b8b1..53f40d2 100644 --- a/core/lib/Drupal/Core/Language/LanguageDefault.php +++ b/core/lib/Drupal/Core/Language/LanguageDefault.php @@ -22,7 +22,7 @@ class LanguageDefault { /** * The default language. * - * @var \Drupal\Core\Language\Language + * @var \Drupal\Core\Language\LanguageInterface */ protected $language; @@ -39,7 +39,7 @@ public function __construct(array $values) { /** * Gets the default language. * - * @return \Drupal\Core\Language\Language + * @return \Drupal\Core\Language\LanguageInterface * The default language. */ public function get() { @@ -49,11 +49,11 @@ public function get() { /** * Sets the default language. * - * @param \Drupal\Core\Language\Language $language + * @param \Drupal\Core\Language\LanguageInterface $language * The default language. */ - public function set(Language $language) { - $language->default = TRUE; + public function set(LanguageInterface $language) { + $language->setDefault(TRUE); $this->language = $language; } diff --git a/core/lib/Drupal/Core/Language/LanguageInterface.php b/core/lib/Drupal/Core/Language/LanguageInterface.php index e718749..d3977b4 100644 --- a/core/lib/Drupal/Core/Language/LanguageInterface.php +++ b/core/lib/Drupal/Core/Language/LanguageInterface.php @@ -208,4 +208,17 @@ public function getNegotiationMethodId(); */ public function setNegotiationMethodId($method_id); + /** + * Checks if the language is locked. + * + * Locked indicates a language used by the system, not an actual language. + * Examples of locked languages are, LANGCODE_NOT_SPECIFIED, und, and + * LANGCODE_NOT_APPLICABLE, zxx, which are usually shown in language selects + * but hidden in places like the Language configuration and cannot be deleted. + * + * @return bool + * TRUE if the language is locked. + */ + public function isLocked(); + } diff --git a/core/lib/Drupal/Core/Language/LanguageManager.php b/core/lib/Drupal/Core/Language/LanguageManager.php index 3d943d0..d738f5a 100644 --- a/core/lib/Drupal/Core/Language/LanguageManager.php +++ b/core/lib/Drupal/Core/Language/LanguageManager.php @@ -26,7 +26,7 @@ class LanguageManager extends DependencySerialization implements LanguageManager /** * An array of all the available languages keyed by language code. * - * @var array + * @var \Drupal\Core\Language\LanguageInterface[] */ protected $languages; @@ -40,7 +40,7 @@ class LanguageManager extends DependencySerialization implements LanguageManager /** * Constructs the language manager. * - * @param \Drupal\Core\Language\Language $default_language + * @param \Drupal\Core\Language\LanguageDefault $default_language * The default language. */ public function __construct(LanguageDefault $default_language) { @@ -80,13 +80,13 @@ public function isMultilingual() { * {@inheritdoc} */ public function getLanguageTypes() { - return array(Language::TYPE_INTERFACE, Language::TYPE_CONTENT, Language::TYPE_URL); + return array(LanguageInterface::TYPE_INTERFACE, LanguageInterface::TYPE_CONTENT, LanguageInterface::TYPE_URL); } /** * {@inheritdoc} */ - public function getCurrentLanguage($type = Language::TYPE_INTERFACE) { + public function getCurrentLanguage($type = LanguageInterface::TYPE_INTERFACE) { return $this->getDefaultLanguage(); } @@ -107,14 +107,14 @@ public function getDefaultLanguage() { /** * {@inheritdoc} */ - public function getLanguages($flags = Language::STATE_CONFIGURABLE) { + public function getLanguages($flags = LanguageInterface::STATE_CONFIGURABLE) { // Initialize master language list. if (!isset($this->languages)) { // No language module, so use the default language only. $default = $this->getDefaultLanguage(); - $this->languages = array($default->id => $default); + $this->languages = array($default->getId() => $default); // Add the special languages, they will be filtered later if needed. - $this->languages += $this->getDefaultLockedLanguages($default->weight); + $this->languages += $this->getDefaultLockedLanguages($default->getWeight()); } // Filter the full list of languages based on the value of the $all flag. By @@ -123,15 +123,15 @@ public function getLanguages($flags = Language::STATE_CONFIGURABLE) { $filtered_languages = array(); // Add the site's default language if flagged as allowed value. - if ($flags & Language::STATE_SITE_DEFAULT) { + if ($flags & LanguageInterface::STATE_SITE_DEFAULT) { $default = isset($default) ? $default : $this->getDefaultLanguage(); // Rename the default language. - $default->name = $this->t("Site's default language (@lang_name)", array('@lang_name' => $default->name)); + $default->setName($this->t("Site's default language (@lang_name)", array('@lang_name' => $default->getName()))); $filtered_languages['site_default'] = $default; } foreach ($this->languages as $id => $language) { - if (($language->locked && ($flags & Language::STATE_LOCKED)) || (!$language->locked && ($flags & Language::STATE_CONFIGURABLE))) { + if (($language->isLocked() && ($flags & LanguageInterface::STATE_LOCKED)) || (!$language->isLocked() && ($flags & LanguageInterface::STATE_CONFIGURABLE))) { $filtered_languages[$id] = $language; } } @@ -143,7 +143,7 @@ public function getLanguages($flags = Language::STATE_CONFIGURABLE) { * {@inheritdoc} */ public function getLanguage($langcode) { - $languages = $this->getLanguages(Language::STATE_ALL); + $languages = $this->getLanguages(LanguageInterface::STATE_ALL); return isset($languages[$langcode]) ? $languages[$langcode] : NULL; } @@ -151,11 +151,11 @@ public function getLanguage($langcode) { * {@inheritdoc} */ public function getLanguageName($langcode) { - if ($langcode == Language::LANGCODE_NOT_SPECIFIED) { + if ($langcode == LanguageInterface::LANGCODE_NOT_SPECIFIED) { return $this->t('None'); } if ($language = $this->getLanguage($langcode)) { - return $language->name; + return $language->getName(); } if (empty($langcode)) { return $this->t('Unknown'); @@ -173,14 +173,14 @@ public function getDefaultLockedLanguages($weight = 0) { 'default' => FALSE, 'locked' => TRUE, ); - $languages[Language::LANGCODE_NOT_SPECIFIED] = new Language(array( - 'id' => Language::LANGCODE_NOT_SPECIFIED, + $languages[LanguageInterface::LANGCODE_NOT_SPECIFIED] = new Language(array( + 'id' => LanguageInterface::LANGCODE_NOT_SPECIFIED, 'name' => $this->t('Not specified'), 'weight' => ++$weight, ) + $locked_language); - $languages[Language::LANGCODE_NOT_APPLICABLE] = new Language(array( - 'id' => Language::LANGCODE_NOT_APPLICABLE, + $languages[LanguageInterface::LANGCODE_NOT_APPLICABLE] = new Language(array( + 'id' => LanguageInterface::LANGCODE_NOT_APPLICABLE, 'name' => $this->t('Not applicable'), 'weight' => ++$weight, ) + $locked_language); @@ -193,14 +193,14 @@ public function getDefaultLockedLanguages($weight = 0) { */ public function isLanguageLocked($langcode) { $language = $this->getLanguage($langcode); - return ($language ? $language->locked : FALSE); + return ($language ? $language->isLocked() : FALSE); } /** * {@inheritdoc} */ public function getFallbackCandidates($langcode = NULL, array $context = array()) { - return array(Language::LANGCODE_DEFAULT); + return array(LanguageInterface::LANGCODE_DEFAULT); } /** @@ -235,7 +235,7 @@ public static function getStandardLanguageList() { return array( 'af' => array('Afrikaans', 'Afrikaans'), 'am' => array('Amharic', 'አማርኛ'), - 'ar' => array('Arabic', /* Left-to-right marker "‭" */ 'العربية', Language::DIRECTION_RTL), + 'ar' => array('Arabic', /* Left-to-right marker "‭" */ 'العربية', LanguageInterface::DIRECTION_RTL), 'ast' => array('Asturian', 'Asturianu'), 'az' => array('Azerbaijani', 'Azərbaycanca'), 'be' => array('Belarusian', 'Беларуская'), @@ -255,7 +255,7 @@ public static function getStandardLanguageList() { 'es' => array('Spanish', 'Español'), 'et' => array('Estonian', 'Eesti'), 'eu' => array('Basque', 'Euskera'), - 'fa' => array('Persian, Farsi', /* Left-to-right marker "‭" */ 'فارسی', Language::DIRECTION_RTL), + 'fa' => array('Persian, Farsi', /* Left-to-right marker "‭" */ 'فارسی', LanguageInterface::DIRECTION_RTL), 'fi' => array('Finnish', 'Suomi'), 'fil' => array('Filipino', 'Filipino'), 'fo' => array('Faeroese', 'Føroyskt'), @@ -266,7 +266,7 @@ public static function getStandardLanguageList() { 'gl' => array('Galician', 'Galego'), 'gsw-berne' => array('Swiss German', 'Schwyzerdütsch'), 'gu' => array('Gujarati', 'ગુજરાતી'), - 'he' => array('Hebrew', /* Left-to-right marker "‭" */ 'עברית', Language::DIRECTION_RTL), + 'he' => array('Hebrew', /* Left-to-right marker "‭" */ 'עברית', LanguageInterface::DIRECTION_RTL), 'hi' => array('Hindi', 'हिन्दी'), 'hr' => array('Croatian', 'Hrvatski'), 'ht' => array('Haitian Creole', 'Kreyòl ayisyen'), @@ -322,7 +322,7 @@ public static function getStandardLanguageList() { 'tyv' => array('Tuvan', 'Тыва дыл'), 'ug' => array('Uyghur', 'Уйғур'), 'uk' => array('Ukrainian', 'Українська'), - 'ur' => array('Urdu', /* Left-to-right marker "‭" */ 'اردو', Language::DIRECTION_RTL), + 'ur' => array('Urdu', /* Left-to-right marker "‭" */ 'اردو', LanguageInterface::DIRECTION_RTL), 'vi' => array('Vietnamese', 'Tiếng Việt'), 'xx-lolspeak' => array('Lolspeak', 'Lolspeak'), 'zh-hans' => array('Chinese, Simplified', '简体中文'), @@ -339,7 +339,7 @@ public static function getStandardLanguageList() { * * @see \Drupal\language\ConfigurableLanguageManager::setConfigOverrideLanguage() */ - public function setConfigOverrideLanguage(Language $language = NULL) { + public function setConfigOverrideLanguage(LanguageInterface $language = NULL) { return $this; } diff --git a/core/lib/Drupal/Core/Language/LanguageManagerInterface.php b/core/lib/Drupal/Core/Language/LanguageManagerInterface.php index 43b2f23..a37327d 100644 --- a/core/lib/Drupal/Core/Language/LanguageManagerInterface.php +++ b/core/lib/Drupal/Core/Language/LanguageManagerInterface.php @@ -48,19 +48,19 @@ public function getLanguageTypes(); * * @param string $type * (optional) The language type, e.g. the interface or the content language. - * Defaults to \Drupal\Core\Language\Language::TYPE_INTERFACE. + * Defaults to \Drupal\Core\Language\LanguageInterface::TYPE_INTERFACE. * - * @return \Drupal\Core\Language\Language + * @return \Drupal\Core\Language\LanguageInterface * A language object for the given type. */ - public function getCurrentLanguage($type = Language::TYPE_INTERFACE); + public function getCurrentLanguage($type = LanguageInterface::TYPE_INTERFACE); /** * Resets the given language type or all types if none specified. * * @param string|null $type * (optional) The language type to reset as a string, e.g., - * Language::TYPE_INTERFACE, or NULL to reset all language types. Defaults + * LanguageInterface::TYPE_INTERFACE, or NULL to reset all language types. Defaults * to NULL. * * @return \Drupal\Core\Language\LanguageManagerInterface @@ -71,7 +71,7 @@ public function reset($type = NULL); /** * Returns a language object representing the site's default language. * - * @return \Drupal\Core\Language\Language + * @return \Drupal\Core\Language\LanguageInterface * A language object. */ public function getDefaultLanguage(); @@ -81,13 +81,13 @@ public function getDefaultLanguage(); * * @param int $flags * (optional) Specifies the state of the languages that have to be returned. - * It can be: Language::STATE_CONFIGURABLE, - * Language::STATE_LOCKED, Language::STATE_ALL. + * It can be: LanguageInterface::STATE_CONFIGURABLE, + * LanguageInterface::STATE_LOCKED, LanguageInterface::STATE_ALL. * - * @return array + * @return \Drupal\Core\Language\LanguageInterface[] * An associative array of languages, keyed by the language code. */ - public function getLanguages($flags = Language::STATE_CONFIGURABLE); + public function getLanguages($flags = LanguageInterface::STATE_CONFIGURABLE); /** * Returns a language object from the given language code. @@ -95,7 +95,7 @@ public function getLanguages($flags = Language::STATE_CONFIGURABLE); * @param string $langcode * The language code. * - * @return \Drupal\core\Language\Language|null + * @return \Drupal\core\Language\LanguageInterface|null * A fully-populated language object or NULL. */ public function getLanguage($langcode); @@ -170,17 +170,17 @@ public function getLanguageSwitchLinks($type, $path); /** * Sets the configuration override language. * - * @param \Drupal\Core\Language\Language $language + * @param \Drupal\Core\Language\LanguageInterface $language * The language to override configuration with. * * @return $this */ - public function setConfigOverrideLanguage(Language $language = NULL); + public function setConfigOverrideLanguage(LanguageInterface $language = NULL); /** * Gets the current configuration override language. * - * @return \Drupal\Core\Language\Language $language + * @return \Drupal\Core\Language\LanguageInterface * The current configuration override language. */ public function getConfigOverrideLanguage(); diff --git a/core/lib/Drupal/Core/Page/DefaultHtmlFragmentRenderer.php b/core/lib/Drupal/Core/Page/DefaultHtmlFragmentRenderer.php index 74ed87b..b4b8300 100644 --- a/core/lib/Drupal/Core/Page/DefaultHtmlFragmentRenderer.php +++ b/core/lib/Drupal/Core/Page/DefaultHtmlFragmentRenderer.php @@ -7,7 +7,6 @@ namespace Drupal\Core\Page; -use Drupal\Core\Language\Language; use Drupal\Core\Language\LanguageManager; /** @@ -82,8 +81,8 @@ public function preparePage(HtmlPage $page, &$page_array) { // HTML element attributes. $language_interface = $this->languageManager->getCurrentLanguage(); $html_attributes = $page->getHtmlAttributes(); - $html_attributes['lang'] = $language_interface->id; - $html_attributes['dir'] = $language_interface->direction ? 'rtl' : 'ltr'; + $html_attributes['lang'] = $language_interface->getId(); + $html_attributes['dir'] = $language_interface->getDirection() ? 'rtl' : 'ltr'; $this->setDefaultMetaTags($page); diff --git a/core/lib/Drupal/Core/Path/AliasManager.php b/core/lib/Drupal/Core/Path/AliasManager.php index 55d2ddc..8d1a8e6 100644 --- a/core/lib/Drupal/Core/Path/AliasManager.php +++ b/core/lib/Drupal/Core/Path/AliasManager.php @@ -7,7 +7,7 @@ namespace Drupal\Core\Path; -use Drupal\Core\Language\Language; +use Drupal\Core\Language\LanguageInterface; use Drupal\Core\Language\LanguageManager; class AliasManager implements AliasManagerInterface { @@ -95,7 +95,7 @@ public function getPathByAlias($alias, $langcode = NULL) { // language. If we used a language different from the one conveyed by the // requested URL, we might end up being unable to check if there is a path // alias matching the URL path. - $langcode = $langcode ?: $this->languageManager->getCurrentLanguage(Language::TYPE_URL)->id; + $langcode = $langcode ?: $this->languageManager->getCurrentLanguage(LanguageInterface::TYPE_URL)->getId(); // If we already know that there are no paths for this alias simply return. if (empty($alias) || !empty($this->noPath[$langcode][$alias])) { @@ -127,7 +127,7 @@ public function getAliasByPath($path, $langcode = NULL) { // language. If we used a language different from the one conveyed by the // requested URL, we might end up being unable to check if there is a path // alias matching the URL path. - $langcode = $langcode ?: $this->languageManager->getCurrentLanguage(Language::TYPE_URL)->id; + $langcode = $langcode ?: $this->languageManager->getCurrentLanguage(LanguageInterface::TYPE_URL)->getId(); // Check the path whitelist, if the top-level part before the first / // is not in the list, then there is no need to do anything further, diff --git a/core/lib/Drupal/Core/Path/AliasStorage.php b/core/lib/Drupal/Core/Path/AliasStorage.php index aa6989c..b405a25 100644 --- a/core/lib/Drupal/Core/Path/AliasStorage.php +++ b/core/lib/Drupal/Core/Path/AliasStorage.php @@ -9,7 +9,7 @@ use Drupal\Core\Database\Connection; use Drupal\Core\Extension\ModuleHandlerInterface; -use Drupal\Core\Language\Language; +use Drupal\Core\Language\LanguageInterface; /** * Provides a class for CRUD operations on path aliases. @@ -46,7 +46,7 @@ public function __construct(Connection $connection, ModuleHandlerInterface $modu /** * {@inheritdoc} */ - public function save($source, $alias, $langcode = Language::LANGCODE_NOT_SPECIFIED, $pid = NULL) { + public function save($source, $alias, $langcode = LanguageInterface::LANGCODE_NOT_SPECIFIED, $pid = NULL) { $fields = array( 'source' => $source, @@ -114,7 +114,7 @@ public function preloadPathAlias($preloaded, $langcode) { $args = array( ':system' => $preloaded, ':langcode' => $langcode, - ':langcode_undetermined' => Language::LANGCODE_NOT_SPECIFIED, + ':langcode_undetermined' => LanguageInterface::LANGCODE_NOT_SPECIFIED, ); // Always get the language-specific alias before the language-neutral one. // For example 'de' is less than 'und' so the order needs to be ASC, while @@ -123,12 +123,12 @@ public function preloadPathAlias($preloaded, $langcode) { // created alias for each source. Subsequent queries using fetchField() must // use pid DESC to have the same effect. For performance reasons, the query // builder is not used here. - if ($langcode == Language::LANGCODE_NOT_SPECIFIED) { + if ($langcode == LanguageInterface::LANGCODE_NOT_SPECIFIED) { // Prevent PDO from complaining about a token the query doesn't use. unset($args[':langcode']); $result = $this->connection->query('SELECT source, alias FROM {url_alias} WHERE source IN (:system) AND langcode = :langcode_undetermined ORDER BY pid ASC', $args); } - elseif ($langcode < Language::LANGCODE_NOT_SPECIFIED) { + elseif ($langcode < LanguageInterface::LANGCODE_NOT_SPECIFIED) { $result = $this->connection->query('SELECT source, alias FROM {url_alias} WHERE source IN (:system) AND langcode IN (:langcode, :langcode_undetermined) ORDER BY langcode ASC, pid ASC', $args); } else { @@ -145,14 +145,14 @@ public function lookupPathAlias($path, $langcode) { $args = array( ':source' => $path, ':langcode' => $langcode, - ':langcode_undetermined' => Language::LANGCODE_NOT_SPECIFIED, + ':langcode_undetermined' => LanguageInterface::LANGCODE_NOT_SPECIFIED, ); // See the queries above. - if ($langcode == Language::LANGCODE_NOT_SPECIFIED) { + if ($langcode == LanguageInterface::LANGCODE_NOT_SPECIFIED) { unset($args[':langcode']); $alias = $this->connection->query("SELECT alias FROM {url_alias} WHERE source = :source AND langcode = :langcode_undetermined ORDER BY pid DESC", $args)->fetchField(); } - elseif ($langcode > Language::LANGCODE_NOT_SPECIFIED) { + elseif ($langcode > LanguageInterface::LANGCODE_NOT_SPECIFIED) { $alias = $this->connection->query("SELECT alias FROM {url_alias} WHERE source = :source AND langcode IN (:langcode, :langcode_undetermined) ORDER BY langcode DESC, pid DESC", $args)->fetchField(); } else { @@ -169,14 +169,14 @@ public function lookupPathSource($path, $langcode) { $args = array( ':alias' => $path, ':langcode' => $langcode, - ':langcode_undetermined' => Language::LANGCODE_NOT_SPECIFIED, + ':langcode_undetermined' => LanguageInterface::LANGCODE_NOT_SPECIFIED, ); // See the queries above. - if ($langcode == Language::LANGCODE_NOT_SPECIFIED) { + if ($langcode == LanguageInterface::LANGCODE_NOT_SPECIFIED) { unset($args[':langcode']); $result = $this->connection->query("SELECT source FROM {url_alias} WHERE alias = :alias AND langcode = :langcode_undetermined ORDER BY pid DESC", $args); } - elseif ($langcode > Language::LANGCODE_NOT_SPECIFIED) { + elseif ($langcode > LanguageInterface::LANGCODE_NOT_SPECIFIED) { $result = $this->connection->query("SELECT source FROM {url_alias} WHERE alias = :alias AND langcode IN (:langcode, :langcode_undetermined) ORDER BY langcode DESC, pid DESC", $args); } else { @@ -217,7 +217,7 @@ public function aliasExists($alias, $langcode, $source = NULL) { * TRUE if aliases with language exist. */ public function languageAliasExists() { - return (bool) $this->connection->queryRange('SELECT 1 FROM {url_alias} WHERE langcode <> :langcode', 0, 1, array(':langcode' => Language::LANGCODE_NOT_SPECIFIED))->fetchField(); + return (bool) $this->connection->queryRange('SELECT 1 FROM {url_alias} WHERE langcode <> :langcode', 0, 1, array(':langcode' => LanguageInterface::LANGCODE_NOT_SPECIFIED))->fetchField(); } /** diff --git a/core/lib/Drupal/Core/Path/AliasStorageInterface.php b/core/lib/Drupal/Core/Path/AliasStorageInterface.php index 68c7cdd..a98600f 100644 --- a/core/lib/Drupal/Core/Path/AliasStorageInterface.php +++ b/core/lib/Drupal/Core/Path/AliasStorageInterface.php @@ -7,7 +7,7 @@ namespace Drupal\Core\Path; -use Drupal\Core\Language\Language; +use Drupal\Core\Language\LanguageInterface; /** * Provides a class for CRUD operations on path aliases. @@ -34,7 +34,7 @@ * - pid (int): Unique path alias identifier. * - langcode (string): The language code of the alias. */ - public function save($source, $alias, $langcode = Language::LANGCODE_NOT_SPECIFIED, $pid = NULL); + public function save($source, $alias, $langcode = LanguageInterface::LANGCODE_NOT_SPECIFIED, $pid = NULL); /** * Fetches a specific URL alias from the database. diff --git a/core/lib/Drupal/Core/PathProcessor/PathProcessorAlias.php b/core/lib/Drupal/Core/PathProcessor/PathProcessorAlias.php index 1c709a1..67226ab 100644 --- a/core/lib/Drupal/Core/PathProcessor/PathProcessorAlias.php +++ b/core/lib/Drupal/Core/PathProcessor/PathProcessorAlias.php @@ -45,7 +45,7 @@ public function processInbound($path, Request $request) { */ public function processOutbound($path, &$options = array(), Request $request = NULL) { if (empty($options['alias'])) { - $langcode = isset($options['language']) ? $options['language']->id : NULL; + $langcode = isset($options['language']) ? $options['language']->getId() : NULL; $path = $this->aliasManager->getAliasByPath($path, $langcode); } return $path; diff --git a/core/lib/Drupal/Core/Plugin/DefaultPluginManager.php b/core/lib/Drupal/Core/Plugin/DefaultPluginManager.php index e9c4ce9..ff6bfff 100644 --- a/core/lib/Drupal/Core/Plugin/DefaultPluginManager.php +++ b/core/lib/Drupal/Core/Plugin/DefaultPluginManager.php @@ -16,7 +16,6 @@ use Drupal\Core\Cache\CacheBackendInterface; use Drupal\Core\Extension\ModuleHandlerInterface; use Drupal\Core\Language\LanguageManagerInterface; -use Drupal\Core\Language\Language; use Drupal\Core\Plugin\Discovery\AnnotatedClassDiscovery; use Drupal\Core\Plugin\Factory\ContainerFactory; @@ -146,7 +145,7 @@ public function setCacheBackend(CacheBackendInterface $cache_backend, LanguageMa $this->languageManager = $language_manager; $this->cacheBackend = $cache_backend; $this->cacheKeyPrefix = $cache_key_prefix; - $this->cacheKey = $cache_key_prefix . ':' . $language_manager->getCurrentLanguage()->id; + $this->cacheKey = $cache_key_prefix . ':' . $language_manager->getCurrentLanguage()->getId(); $this->cacheTags = $cache_tags; } diff --git a/core/lib/Drupal/Core/Routing/UrlGeneratorInterface.php b/core/lib/Drupal/Core/Routing/UrlGeneratorInterface.php index 686f0d3..b191729 100644 --- a/core/lib/Drupal/Core/Routing/UrlGeneratorInterface.php +++ b/core/lib/Drupal/Core/Routing/UrlGeneratorInterface.php @@ -55,7 +55,7 @@ * - 'language': An optional language object. If the path being linked to is * internal to the site, $options['language'] is used to look up the alias * for the URL. If $options['language'] is omitted, the language will be - * obtained from \Drupal::languageManager()->getCurrentLanguage(Language::TYPE_URL). + * obtained from \Drupal::languageManager()->getCurrentLanguage(LanguageInterface::TYPE_URL). * - 'https': Whether this URL should point to a secure location. If not * defined, the current scheme is used, so the user stays on HTTP or HTTPS * respectively. TRUE enforces HTTPS and FALSE enforces HTTP, but HTTPS can @@ -122,7 +122,7 @@ public function getPathFromRoute($name, $parameters = array()); * displayed outside the site, such as in an RSS feed. * - 'language': An optional language object used to look up the alias * for the URL. If $options['language'] is omitted, it defaults to the - * current language for the language type Language::TYPE_URL. + * current language for the language type LanguageInterface::TYPE_URL. * - 'https': Whether this URL should point to a secure location. If not * defined, the current scheme is used, so the user stays on HTTP or HTTPS * respectively. if mixed mode sessions are permitted, TRUE enforces HTTPS diff --git a/core/lib/Drupal/Core/Session/UserSession.php b/core/lib/Drupal/Core/Session/UserSession.php index 704fc79..a1a8cd0 100644 --- a/core/lib/Drupal/Core/Session/UserSession.php +++ b/core/lib/Drupal/Core/Session/UserSession.php @@ -193,10 +193,10 @@ public function isAnonymous() { function getPreferredLangcode($default = NULL) { $language_list = language_list(); if (!empty($this->preferred_langcode) && isset($language_list[$this->preferred_langcode])) { - return $language_list[$this->preferred_langcode]->id; + return $language_list[$this->preferred_langcode]->getId(); } else { - return $default ? $default : language_default()->id; + return $default ? $default : language_default()->getId(); } } @@ -206,10 +206,10 @@ function getPreferredLangcode($default = NULL) { function getPreferredAdminLangcode($default = NULL) { $language_list = language_list(); if (!empty($this->preferred_admin_langcode) && isset($language_list[$this->preferred_admin_langcode])) { - return $language_list[$this->preferred_admin_langcode]->id; + return $language_list[$this->preferred_admin_langcode]->getId(); } else { - return $default ? $default : language_default()->id; + return $default ? $default : language_default()->getId(); } } diff --git a/core/lib/Drupal/Core/StringTranslation/TranslationManager.php b/core/lib/Drupal/Core/StringTranslation/TranslationManager.php index bd1b3b3..f8b6bb1 100644 --- a/core/lib/Drupal/Core/StringTranslation/TranslationManager.php +++ b/core/lib/Drupal/Core/StringTranslation/TranslationManager.php @@ -60,7 +60,7 @@ class TranslationManager implements TranslationInterface, TranslatorInterface { */ public function __construct(LanguageManagerInterface $language_manager) { $this->languageManager = $language_manager; - $this->defaultLangcode = $language_manager->getDefaultLanguage()->id; + $this->defaultLangcode = $language_manager->getDefaultLanguage()->getId(); } /** diff --git a/core/lib/Drupal/Core/TypedData/Plugin/DataType/Language.php b/core/lib/Drupal/Core/TypedData/Plugin/DataType/Language.php index 510a869..8be31e5 100644 --- a/core/lib/Drupal/Core/TypedData/Plugin/DataType/Language.php +++ b/core/lib/Drupal/Core/TypedData/Plugin/DataType/Language.php @@ -57,7 +57,7 @@ public function getValue() { public function setValue($value, $notify = TRUE) { // Support passing language objects. if (is_object($value)) { - $this->id = $value->id; + $this->id = $value->getId(); $this->language = $value; } elseif (isset($value) && !is_scalar($value)) { diff --git a/core/lib/Drupal/Core/TypedData/TranslatableInterface.php b/core/lib/Drupal/Core/TypedData/TranslatableInterface.php index 8632edb..557a17e 100644 --- a/core/lib/Drupal/Core/TypedData/TranslatableInterface.php +++ b/core/lib/Drupal/Core/TypedData/TranslatableInterface.php @@ -29,7 +29,7 @@ public function language(); * (optional) Whether the default language should be included. Defaults to * TRUE. * - * @return + * @return \Drupal\Core\Language\LanguageInterface[] * An array of language objects, keyed by language codes. */ public function getTranslationLanguages($include_default = TRUE); @@ -42,7 +42,7 @@ public function getTranslationLanguages($include_default = TRUE); * instantiated. * * @param $langcode - * The language code of the translation to get or Language::LANGCODE_DEFAULT + * The language code of the translation to get or LanguageInterface::LANGCODE_DEFAULT * to get the data in default language. * * @return \Drupal\Core\TypedData\TypedDataInterface diff --git a/core/lib/Drupal/Core/Url.php b/core/lib/Drupal/Core/Url.php index 93b329a..f7f2b1a 100644 --- a/core/lib/Drupal/Core/Url.php +++ b/core/lib/Drupal/Core/Url.php @@ -83,7 +83,7 @@ class Url extends DependencySerialization { * displayed outside the site, such as in an RSS feed. * - 'language': An optional language object used to look up the alias * for the URL. If $options['language'] is omitted, it defaults to the - * current language for the language type Language::TYPE_URL. + * current language for the language type LanguageInterface::TYPE_URL. * - 'https': Whether this URL should point to a secure location. If not * defined, the current scheme is used, so the user stays on HTTP or HTTPS * respectively. if mixed mode sessions are permitted, TRUE enforces HTTPS diff --git a/core/lib/Drupal/Core/Utility/LinkGenerator.php b/core/lib/Drupal/Core/Utility/LinkGenerator.php index b547d95..2c38b45 100644 --- a/core/lib/Drupal/Core/Utility/LinkGenerator.php +++ b/core/lib/Drupal/Core/Utility/LinkGenerator.php @@ -81,7 +81,7 @@ public function generateFromUrl($text, Url $url) { // Add a hreflang attribute if we know the language of this link's url and // hreflang has not already been set. if (!empty($variables['options']['language']) && !isset($variables['options']['attributes']['hreflang'])) { - $variables['options']['attributes']['hreflang'] = $variables['options']['language']->id; + $variables['options']['attributes']['hreflang'] = $variables['options']['language']->getId(); } // Set the "active" class if the 'set_active_class' option is not empty. diff --git a/core/lib/Drupal/Core/Utility/Token.php b/core/lib/Drupal/Core/Utility/Token.php index 4a1238e..73376e1 100644 --- a/core/lib/Drupal/Core/Utility/Token.php +++ b/core/lib/Drupal/Core/Utility/Token.php @@ -9,7 +9,7 @@ use Drupal\Core\Cache\CacheBackendInterface; use Drupal\Core\Extension\ModuleHandlerInterface; -use Drupal\Core\Language\Language; +use Drupal\Core\Language\LanguageInterface; use Drupal\Core\Language\LanguageManagerInterface; /** @@ -311,7 +311,7 @@ public function findWithPrefix(array $tokens, $prefix, $delimiter = ':') { */ public function getInfo() { if (is_null($this->tokenInfo)) { - $cache_id = 'token_info:' . $this->languageManager->getCurrentLanguage(Language::TYPE_CONTENT)->id; + $cache_id = 'token_info:' . $this->languageManager->getCurrentLanguage(LanguageInterface::TYPE_CONTENT)->getId(); $cache = $this->cache->get($cache_id); if ($cache) { $this->tokenInfo = $cache->data; diff --git a/core/lib/Drupal/Core/Validation/DrupalTranslator.php b/core/lib/Drupal/Core/Validation/DrupalTranslator.php index 5b4d99d..84847a5 100644 --- a/core/lib/Drupal/Core/Validation/DrupalTranslator.php +++ b/core/lib/Drupal/Core/Validation/DrupalTranslator.php @@ -7,7 +7,6 @@ namespace Drupal\Core\Validation; -use Drupal\Core\Language\Language; use Symfony\Component\Translation\TranslatorInterface; /** @@ -56,7 +55,7 @@ public function setLocale($locale) { * Implements \Symfony\Component\Translation\TranslatorInterface::getLocale(). */ public function getLocale() { - return $this->locale ? $this->locale : \Drupal::languageManager()->getCurrentLanguage()->id; + return $this->locale ? $this->locale : \Drupal::languageManager()->getCurrentLanguage()->getId(); } /** diff --git a/core/modules/aggregator/aggregator.install b/core/modules/aggregator/aggregator.install index e4bef0e..028f8cd 100644 --- a/core/modules/aggregator/aggregator.install +++ b/core/modules/aggregator/aggregator.install @@ -4,7 +4,6 @@ * @file * Install, update and uninstall functions for the aggregator module. */ -use Drupal\Core\Language\Language; /** * Implements hook_requirements(). diff --git a/core/modules/aggregator/lib/Drupal/aggregator/FeedForm.php b/core/modules/aggregator/lib/Drupal/aggregator/FeedForm.php index 1770f03..f2f35aa 100644 --- a/core/modules/aggregator/lib/Drupal/aggregator/FeedForm.php +++ b/core/modules/aggregator/lib/Drupal/aggregator/FeedForm.php @@ -10,7 +10,7 @@ use Drupal\Component\Utility\String; use Drupal\Core\Entity\ContentEntityForm; use Drupal\Core\Entity\EntityManagerInterface; -use Drupal\Core\Language\Language; +use Drupal\Core\Language\LanguageInterface; use Symfony\Component\DependencyInjection\ContainerInterface; /** @@ -30,8 +30,8 @@ public function form(array $form, array &$form_state) { $form['langcode'] = array( '#title' => $this->t('Language'), '#type' => 'language_select', - '#default_value' => $feed->language()->id, - '#languages' => Language::STATE_ALL, + '#default_value' => $feed->language()->getId(), + '#languages' => LanguageInterface::STATE_ALL, '#weight' => -4, ); diff --git a/core/modules/aggregator/lib/Drupal/aggregator/Plugin/aggregator/processor/DefaultProcessor.php b/core/modules/aggregator/lib/Drupal/aggregator/Plugin/aggregator/processor/DefaultProcessor.php index 058ba18..13de3e0 100644 --- a/core/modules/aggregator/lib/Drupal/aggregator/Plugin/aggregator/processor/DefaultProcessor.php +++ b/core/modules/aggregator/lib/Drupal/aggregator/Plugin/aggregator/processor/DefaultProcessor.php @@ -190,7 +190,7 @@ public function process(FeedInterface $feed) { $entry = reset($entry); } else { - $entry = entity_create('aggregator_item', array('langcode' => $feed->language()->id)); + $entry = entity_create('aggregator_item', array('langcode' => $feed->language()->getId())); } if ($item['timestamp']) { $entry->setPostedTime($item['timestamp']); diff --git a/core/modules/aggregator/lib/Drupal/aggregator/Tests/AggregatorTestBase.php b/core/modules/aggregator/lib/Drupal/aggregator/Tests/AggregatorTestBase.php index 6a85657..fe052e4 100644 --- a/core/modules/aggregator/lib/Drupal/aggregator/Tests/AggregatorTestBase.php +++ b/core/modules/aggregator/lib/Drupal/aggregator/Tests/AggregatorTestBase.php @@ -7,7 +7,6 @@ namespace Drupal\aggregator\Tests; -use Drupal\Core\Language\Language; use Drupal\simpletest\WebTestBase; use Drupal\aggregator\FeedInterface; diff --git a/core/modules/aggregator/lib/Drupal/aggregator/Tests/FeedLanguageTest.php b/core/modules/aggregator/lib/Drupal/aggregator/Tests/FeedLanguageTest.php index d297abc..29a1863 100644 --- a/core/modules/aggregator/lib/Drupal/aggregator/Tests/FeedLanguageTest.php +++ b/core/modules/aggregator/lib/Drupal/aggregator/Tests/FeedLanguageTest.php @@ -24,7 +24,7 @@ class FeedLanguageTest extends AggregatorTestBase { /** * List of langcodes. * - * @var array + * @var \Drupal\Core\Language\LanguageInterface[] */ protected $langcodes = array(); @@ -55,14 +55,15 @@ public function setUp() { * Tests creation of feeds with a language. */ public function testFeedLanguage() { + /** @var \Drupal\aggregator\FeedInterface[] $feeds */ $feeds = array(); // Create feeds. - $feeds[1] = $this->createFeed(NULL, array('langcode' => $this->langcodes[1]->id)); - $feeds[2] = $this->createFeed(NULL, array('langcode' => $this->langcodes[2]->id)); + $feeds[1] = $this->createFeed(NULL, array('langcode' => $this->langcodes[1]->getId())); + $feeds[2] = $this->createFeed(NULL, array('langcode' => $this->langcodes[2]->getId())); // Make sure that the language has been assigned. - $this->assertEqual($feeds[1]->language()->id, $this->langcodes[1]->id); - $this->assertEqual($feeds[2]->language()->id, $this->langcodes[2]->id); + $this->assertEqual($feeds[1]->language()->getId(), $this->langcodes[1]->getId()); + $this->assertEqual($feeds[2]->language()->getId(), $this->langcodes[2]->getId()); // Create example nodes to create feed items from and then update the feeds. $this->createSampleNodes(); @@ -71,10 +72,11 @@ public function testFeedLanguage() { // Loop over the created feed items and verify that their language matches // the one from the feed. foreach ($feeds as $feed) { + /** @var \Drupal\aggregator\ItemInterface[] $items */ $items = entity_load_multiple_by_properties('aggregator_item', array('fid' => $feed->id())); $this->assertTrue(count($items) > 0, 'Feed items were created.'); foreach ($items as $item) { - $this->assertEqual($item->language()->id, $feed->language()->id); + $this->assertEqual($item->language()->getId(), $feed->language()->getId()); } } } diff --git a/core/modules/block/block.install b/core/modules/block/block.install index a53a120..0d1ca69 100644 --- a/core/modules/block/block.install +++ b/core/modules/block/block.install @@ -5,8 +5,6 @@ * Install, update and uninstall functions for the block module. */ -use Drupal\Core\Language\Language; - /** * Implements hook_install(). */ diff --git a/core/modules/block/custom_block/lib/Drupal/custom_block/CustomBlockForm.php b/core/modules/block/custom_block/lib/Drupal/custom_block/CustomBlockForm.php index f495c4f..090f529 100644 --- a/core/modules/block/custom_block/lib/Drupal/custom_block/CustomBlockForm.php +++ b/core/modules/block/custom_block/lib/Drupal/custom_block/CustomBlockForm.php @@ -11,7 +11,7 @@ use Drupal\Core\Entity\ContentEntityForm; use Drupal\Core\Entity\EntityManagerInterface; use Drupal\Core\Entity\EntityStorageInterface; -use Drupal\Core\Language\Language; +use Drupal\Core\Language\LanguageInterface; use Drupal\Core\Language\LanguageManager; use Symfony\Component\DependencyInjection\ContainerInterface; @@ -102,15 +102,15 @@ public function form(array $form, array &$form_state) { // Set the correct default language. if ($block->isNew()) { $language_default = $this->languageManager->getCurrentLanguage($language_configuration['langcode']); - $block->langcode->value = $language_default->id; + $block->langcode->value = $language_default->getId(); } } $form['langcode'] = array( '#title' => $this->t('Language'), '#type' => 'language_select', - '#default_value' => $block->getUntranslated()->language()->id, - '#languages' => Language::STATE_ALL, + '#default_value' => $block->getUntranslated()->language()->getId(), + '#languages' => LanguageInterface::STATE_ALL, '#access' => isset($language_configuration['language_show']) && $language_configuration['language_show'], ); diff --git a/core/modules/block/custom_block/lib/Drupal/custom_block/Tests/CustomBlockSaveTest.php b/core/modules/block/custom_block/lib/Drupal/custom_block/Tests/CustomBlockSaveTest.php index ff0192e..aa18c5d 100644 --- a/core/modules/block/custom_block/lib/Drupal/custom_block/Tests/CustomBlockSaveTest.php +++ b/core/modules/block/custom_block/lib/Drupal/custom_block/Tests/CustomBlockSaveTest.php @@ -7,8 +7,6 @@ namespace Drupal\custom_block\Tests; -use Drupal\Core\Language\Language; - /** * Tests block save related functionality. */ diff --git a/core/modules/block/custom_block/lib/Drupal/custom_block/Tests/CustomBlockTypeTest.php b/core/modules/block/custom_block/lib/Drupal/custom_block/Tests/CustomBlockTypeTest.php index 896ad7c..5bdbf92 100644 --- a/core/modules/block/custom_block/lib/Drupal/custom_block/Tests/CustomBlockTypeTest.php +++ b/core/modules/block/custom_block/lib/Drupal/custom_block/Tests/CustomBlockTypeTest.php @@ -66,7 +66,7 @@ public function testCustomBlockTypeCreation() { $this->assertTrue($block_type, 'The new block type has been created.'); // Check that the block type was created in site default language. - $default_langcode = \Drupal::languageManager()->getDefaultLanguage()->id; + $default_langcode = \Drupal::languageManager()->getDefaultLanguage()->getId(); $this->assertEqual($block_type->langcode, $default_langcode); } diff --git a/core/modules/block/custom_block/lib/Drupal/custom_block/Tests/PageEditTest.php b/core/modules/block/custom_block/lib/Drupal/custom_block/Tests/PageEditTest.php index 8062fb5..e39c81f 100644 --- a/core/modules/block/custom_block/lib/Drupal/custom_block/Tests/PageEditTest.php +++ b/core/modules/block/custom_block/lib/Drupal/custom_block/Tests/PageEditTest.php @@ -7,8 +7,6 @@ namespace Drupal\custom_block\Tests; -use Drupal\Core\Language\Language; - /** * Tests the block edit functionality. */ diff --git a/core/modules/block/lib/Drupal/block/BlockAccessController.php b/core/modules/block/lib/Drupal/block/BlockAccessController.php index 9e4e472..6f2c951 100644 --- a/core/modules/block/lib/Drupal/block/BlockAccessController.php +++ b/core/modules/block/lib/Drupal/block/BlockAccessController.php @@ -117,7 +117,7 @@ protected function checkAccess(EntityInterface $entity, $operation, $langcode, A // Language visibility settings. if (!empty($visibility['language']['langcodes']) && array_filter($visibility['language']['langcodes'])) { - if (empty($visibility['language']['langcodes'][\Drupal::languageManager()->getCurrentLanguage($visibility['language']['language_type'])->id])) { + if (empty($visibility['language']['langcodes'][\Drupal::languageManager()->getCurrentLanguage($visibility['language']['language_type'])->getId()])) { return FALSE; } } diff --git a/core/modules/block/lib/Drupal/block/BlockBase.php b/core/modules/block/lib/Drupal/block/BlockBase.php index e50a18c..6989a4a 100644 --- a/core/modules/block/lib/Drupal/block/BlockBase.php +++ b/core/modules/block/lib/Drupal/block/BlockBase.php @@ -11,7 +11,7 @@ use Drupal\block\BlockInterface; use Drupal\Component\Utility\Unicode; use Drupal\Component\Utility\NestedArray; -use Drupal\Core\Language\Language; +use Drupal\Core\Language\LanguageInterface; use Drupal\Core\Cache\Cache; use Drupal\Core\Cache\CacheableInterface; use Drupal\Core\Session\AccountInterface; @@ -262,7 +262,7 @@ public function getMachineNameSuggestion() { // \Drupal\system\MachineNameController::transliterate(), so it might make // sense to provide a common service for the two. $transliteration_service = \Drupal::transliteration(); - $transliterated = $transliteration_service->transliterate($admin_label, Language::LANGCODE_DEFAULT, '_'); + $transliterated = $transliteration_service->transliterate($admin_label, LanguageInterface::LANGCODE_DEFAULT, '_'); $replace_pattern = '[^a-z0-9_.]+'; diff --git a/core/modules/block/lib/Drupal/block/BlockForm.php b/core/modules/block/lib/Drupal/block/BlockForm.php index d614dce..aded250 100644 --- a/core/modules/block/lib/Drupal/block/BlockForm.php +++ b/core/modules/block/lib/Drupal/block/BlockForm.php @@ -10,7 +10,7 @@ use Drupal\Core\Cache\Cache; use Drupal\Core\Entity\EntityForm; use Drupal\Core\Entity\EntityManagerInterface; -use Drupal\Core\Language\Language; +use Drupal\Core\Language\LanguageInterface; use Drupal\Core\Language\LanguageManagerInterface; use Drupal\language\ConfigurableLanguageManagerInterface; use Symfony\Component\DependencyInjection\ContainerInterface; @@ -157,12 +157,12 @@ public function form(array $form, array &$form_state) { $language_types = $this->languageManager->getLanguageTypes(); // Fetch languages. - $languages = $this->languageManager->getLanguages(Language::STATE_ALL); + $languages = $this->languageManager->getLanguages(LanguageInterface::STATE_ALL); $langcodes_options = array(); foreach ($languages as $language) { - // @todo $language->name is not wrapped with t(), it should be replaced + // @todo $language->getName() is not wrapped with t(), it should be replaced // by CMI translation implementation. - $langcodes_options[$language->id] = $language->name; + $langcodes_options[$language->getId()] = $language->getName(); } $form['visibility']['language'] = array( '#type' => 'details', diff --git a/core/modules/block/lib/Drupal/block/Tests/BlockStorageUnitTest.php b/core/modules/block/lib/Drupal/block/Tests/BlockStorageUnitTest.php index 65d67f6..48f5a18 100644 --- a/core/modules/block/lib/Drupal/block/Tests/BlockStorageUnitTest.php +++ b/core/modules/block/lib/Drupal/block/Tests/BlockStorageUnitTest.php @@ -93,7 +93,7 @@ protected function createTests() { 'id' => 'test_block', 'weight' => NULL, 'status' => TRUE, - 'langcode' => \Drupal::languageManager()->getDefaultLanguage()->id, + 'langcode' => \Drupal::languageManager()->getDefaultLanguage()->getId(), 'dependencies' => array('module' => array('block_test'), 'theme' => array('stark')), 'theme' => 'stark', 'region' => '-1', diff --git a/core/modules/book/book.module b/core/modules/book/book.module index 9cc4835..fcd8459 100644 --- a/core/modules/book/book.module +++ b/core/modules/book/book.module @@ -11,7 +11,7 @@ use Drupal\Core\Render\Element; use Drupal\node\NodeInterface; use Drupal\node\NodeTypeInterface; -use Drupal\Core\Language\Language; +use Drupal\Core\Language\LanguageInterface; use Drupal\Core\Entity\Display\EntityViewDisplayInterface; use Drupal\Core\Template\Attribute; use Symfony\Component\HttpFoundation\Request; @@ -491,13 +491,13 @@ function template_preprocess_book_export_html(&$variables) { $variables['title'] = String::checkPlain($variables['title']); $variables['base_url'] = $base_url; $variables['language'] = $language_interface; - $variables['language_rtl'] = ($language_interface->direction == Language::DIRECTION_RTL); + $variables['language_rtl'] = ($language_interface->getDirection() == LanguageInterface::DIRECTION_RTL); $variables['head'] = drupal_get_html_head(); // HTML element attributes. $attributes = array(); - $attributes['lang'] = $language_interface->id; - $attributes['dir'] = $language_interface->direction ? 'rtl' : 'ltr'; + $attributes['lang'] = $language_interface->getId(); + $attributes['dir'] = $language_interface->getDirection() ? 'rtl' : 'ltr'; $variables['html_attributes'] = new Attribute($attributes); } diff --git a/core/modules/book/lib/Drupal/book/BookManager.php b/core/modules/book/lib/Drupal/book/BookManager.php index c491cf4..84a43d2 100644 --- a/core/modules/book/lib/Drupal/book/BookManager.php +++ b/core/modules/book/lib/Drupal/book/BookManager.php @@ -465,7 +465,7 @@ public function bookTreeAllData($bid, $link = NULL, $max_depth = NULL) { $nid = isset($link['nid']) ? $link['nid'] : 0; // Generate a cache ID (cid) specific for this $bid, $link, $language, and // depth. - $cid = 'book-links:' . $bid . ':all:' . $nid . ':' . $language_interface->id . ':' . (int) $max_depth; + $cid = 'book-links:' . $bid . ':all:' . $nid . ':' . $language_interface->getId() . ':' . (int) $max_depth; if (!isset($tree[$cid])) { // If the tree data was not in the static cache, build $tree_parameters. @@ -618,7 +618,7 @@ protected function doBookTreeBuild($bid, array $parameters = array()) { if (isset($parameters['expanded'])) { sort($parameters['expanded']); } - $tree_cid = 'book-links:' . $bid . ':tree-data:' . $language_interface->id . ':' . hash('sha256', serialize($parameters)); + $tree_cid = 'book-links:' . $bid . ':tree-data:' . $language_interface->getId() . ':' . hash('sha256', serialize($parameters)); // If we do not have this tree in the static cache, check {cache_data}. if (!isset($trees[$tree_cid])) { diff --git a/core/modules/ckeditor/ckeditor.admin.inc b/core/modules/ckeditor/ckeditor.admin.inc index 373ebd2..a4b779d 100644 --- a/core/modules/ckeditor/ckeditor.admin.inc +++ b/core/modules/ckeditor/ckeditor.admin.inc @@ -5,7 +5,6 @@ * Callbacks and theming for the CKEditor toolbar configuration UI. */ -use Drupal\Core\Language\Language; use Drupal\Core\Template\Attribute; /** @@ -21,7 +20,7 @@ function template_preprocess_ckeditor_settings_toolbar(&$variables) { // Simplify the language direction information for toolbar buttons. $language_interface = \Drupal::languageManager()->getCurrentLanguage(); - $language_direction = $language_interface->direction ? 'rtl' : 'ltr'; + $language_direction = $language_interface->getDirection() ? 'rtl' : 'ltr'; // Create lists of active and disabled buttons. $editor = $variables['editor']; diff --git a/core/modules/ckeditor/lib/Drupal/ckeditor/Plugin/Editor/CKEditor.php b/core/modules/ckeditor/lib/Drupal/ckeditor/Plugin/Editor/CKEditor.php index cc6af2f..8f5642a 100644 --- a/core/modules/ckeditor/lib/Drupal/ckeditor/Plugin/Editor/CKEditor.php +++ b/core/modules/ckeditor/lib/Drupal/ckeditor/Plugin/Editor/CKEditor.php @@ -10,7 +10,6 @@ use Drupal\Core\Cache\CacheBackendInterface; use Drupal\Core\Extension\ModuleHandlerInterface; use Drupal\ckeditor\CKEditorPluginManager; -use Drupal\Core\Language\Language; use Drupal\Core\Language\LanguageManager; use Drupal\Core\Render\Element; use Drupal\editor\Plugin\EditorBase; @@ -271,8 +270,8 @@ public function getJSSettings(EditorEntity $editor) { // Map the interface language code to a CKEditor translation. $ckeditor_langcodes = $this->getLangcodes(); $language_interface = $this->languageManager->getCurrentLanguage(); - if (isset($ckeditor_langcodes[$language_interface->id])) { - $display_langcode = $ckeditor_langcodes[$language_interface->id]; + if (isset($ckeditor_langcodes[$language_interface->getId()])) { + $display_langcode = $ckeditor_langcodes[$language_interface->getId()]; } // Next, set the most fundamental CKEditor settings. diff --git a/core/modules/comment/lib/Drupal/comment/CommentForm.php b/core/modules/comment/lib/Drupal/comment/CommentForm.php index 6fd7ff6..9199a8e 100644 --- a/core/modules/comment/lib/Drupal/comment/CommentForm.php +++ b/core/modules/comment/lib/Drupal/comment/CommentForm.php @@ -14,7 +14,7 @@ use Drupal\Core\Datetime\DrupalDateTime; use Drupal\Core\Entity\ContentEntityForm; use Drupal\Core\Entity\EntityManagerInterface; -use Drupal\Core\Language\Language; +use Drupal\Core\Language\LanguageInterface; use Drupal\Core\Session\AccountInterface; use Symfony\Component\DependencyInjection\ContainerInterface; @@ -64,8 +64,8 @@ protected function init(array &$form_state) { // Make the comment inherit the current content language unless specifically // set. if ($comment->isNew()) { - $language_content = \Drupal::languageManager()->getCurrentLanguage(Language::TYPE_CONTENT); - $comment->langcode->value = $language_content->id; + $language_content = \Drupal::languageManager()->getCurrentLanguage(LanguageInterface::TYPE_CONTENT); + $comment->langcode->value = $language_content->getId(); } parent::init($form_state); diff --git a/core/modules/comment/lib/Drupal/comment/CommentViewBuilder.php b/core/modules/comment/lib/Drupal/comment/CommentViewBuilder.php index 5a75d43..b79a088 100644 --- a/core/modules/comment/lib/Drupal/comment/CommentViewBuilder.php +++ b/core/modules/comment/lib/Drupal/comment/CommentViewBuilder.php @@ -15,7 +15,6 @@ use Drupal\Core\Entity\EntityTypeInterface; use Drupal\Core\Entity\EntityViewBuilder; use Drupal\entity\Entity\EntityViewDisplay; -use Drupal\Core\Language\Language; use Drupal\Core\Language\LanguageManagerInterface; use Symfony\Component\DependencyInjection\ContainerInterface; diff --git a/core/modules/comment/lib/Drupal/comment/Entity/Comment.php b/core/modules/comment/lib/Drupal/comment/Entity/Comment.php index de10346..3eb2a7b 100644 --- a/core/modules/comment/lib/Drupal/comment/Entity/Comment.php +++ b/core/modules/comment/lib/Drupal/comment/Entity/Comment.php @@ -13,7 +13,6 @@ use Drupal\Core\Entity\EntityStorageInterface; use Drupal\Core\Entity\EntityTypeInterface; use Drupal\Core\Field\FieldDefinition; -use Drupal\Core\Language\Language; use Drupal\Core\TypedData\DataDefinition; use Drupal\user\UserInterface; diff --git a/core/modules/comment/lib/Drupal/comment/Tests/CommentCSSTest.php b/core/modules/comment/lib/Drupal/comment/Tests/CommentCSSTest.php index 8c2df9b..8c34754 100644 --- a/core/modules/comment/lib/Drupal/comment/Tests/CommentCSSTest.php +++ b/core/modules/comment/lib/Drupal/comment/Tests/CommentCSSTest.php @@ -7,7 +7,7 @@ namespace Drupal\comment\Tests; -use Drupal\Core\Language\Language; +use Drupal\Core\Language\LanguageInterface; use Drupal\comment\CommentInterface; /** @@ -59,8 +59,8 @@ function testCommentClasses() { 'uid' => $case['comment_uid'], 'status' => $case['comment_status'], 'subject' => $this->randomName(), - 'language' => Language::LANGCODE_NOT_SPECIFIED, - 'comment_body' => array(Language::LANGCODE_NOT_SPECIFIED => array($this->randomName())), + 'language' => LanguageInterface::LANGCODE_NOT_SPECIFIED, + 'comment_body' => array(LanguageInterface::LANGCODE_NOT_SPECIFIED => array($this->randomName())), )); $comment->save(); diff --git a/core/modules/comment/lib/Drupal/comment/Tests/CommentLinksTest.php b/core/modules/comment/lib/Drupal/comment/Tests/CommentLinksTest.php index cf7af82..bce2746 100644 --- a/core/modules/comment/lib/Drupal/comment/Tests/CommentLinksTest.php +++ b/core/modules/comment/lib/Drupal/comment/Tests/CommentLinksTest.php @@ -8,7 +8,7 @@ namespace Drupal\comment\Tests; use Drupal\comment\Plugin\Field\FieldType\CommentItemInterface; -use Drupal\Core\Language\Language; +use Drupal\Core\Language\LanguageInterface; use Drupal\comment\CommentInterface; /** @@ -152,8 +152,8 @@ function setEnvironment(array $info) { 'status' => CommentInterface::PUBLISHED, 'subject' => $this->randomName(), 'hostname' => '127.0.0.1', - 'langcode' => Language::LANGCODE_NOT_SPECIFIED, - 'comment_body' => array(Language::LANGCODE_NOT_SPECIFIED => array($this->randomName())), + 'langcode' => LanguageInterface::LANGCODE_NOT_SPECIFIED, + 'comment_body' => array(LanguageInterface::LANGCODE_NOT_SPECIFIED => array($this->randomName())), )); $comment->save(); $this->comment = $comment; diff --git a/core/modules/comment/lib/Drupal/comment/Tests/CommentNewIndicatorTest.php b/core/modules/comment/lib/Drupal/comment/Tests/CommentNewIndicatorTest.php index fbe36d2..f955b62 100644 --- a/core/modules/comment/lib/Drupal/comment/Tests/CommentNewIndicatorTest.php +++ b/core/modules/comment/lib/Drupal/comment/Tests/CommentNewIndicatorTest.php @@ -8,7 +8,7 @@ namespace Drupal\comment\Tests; use Drupal\Component\Serialization\Json; -use Drupal\Core\Language\Language; +use Drupal\Core\Language\LanguageInterface; use Drupal\comment\CommentInterface; /** @@ -100,8 +100,8 @@ public function testCommentNewCommentsIndicator() { 'status' => CommentInterface::PUBLISHED, 'subject' => $this->randomName(), 'hostname' => '127.0.0.1', - 'langcode' => Language::LANGCODE_NOT_SPECIFIED, - 'comment_body' => array(Language::LANGCODE_NOT_SPECIFIED => array($this->randomName())), + 'langcode' => LanguageInterface::LANGCODE_NOT_SPECIFIED, + 'comment_body' => array(LanguageInterface::LANGCODE_NOT_SPECIFIED => array($this->randomName())), )); $comment->save(); $this->drupalLogout(); diff --git a/core/modules/comment/lib/Drupal/comment/Tests/CommentTestBase.php b/core/modules/comment/lib/Drupal/comment/Tests/CommentTestBase.php index c1edf13..29f2033 100644 --- a/core/modules/comment/lib/Drupal/comment/Tests/CommentTestBase.php +++ b/core/modules/comment/lib/Drupal/comment/Tests/CommentTestBase.php @@ -7,7 +7,6 @@ namespace Drupal\comment\Tests; -use Drupal\Core\Language\Language; use Drupal\comment\CommentInterface; use Drupal\simpletest\WebTestBase; diff --git a/core/modules/comment/lib/Drupal/comment/Tests/CommentThreadingTest.php b/core/modules/comment/lib/Drupal/comment/Tests/CommentThreadingTest.php index f69b55f..85c2342 100644 --- a/core/modules/comment/lib/Drupal/comment/Tests/CommentThreadingTest.php +++ b/core/modules/comment/lib/Drupal/comment/Tests/CommentThreadingTest.php @@ -7,7 +7,6 @@ namespace Drupal\comment\Tests; -use Drupal\Core\Language\Language; /** * Tests comment threading. diff --git a/core/modules/comment/lib/Drupal/comment/Tests/CommentTokenReplaceTest.php b/core/modules/comment/lib/Drupal/comment/Tests/CommentTokenReplaceTest.php index 0d2a4b2..d126998 100644 --- a/core/modules/comment/lib/Drupal/comment/Tests/CommentTokenReplaceTest.php +++ b/core/modules/comment/lib/Drupal/comment/Tests/CommentTokenReplaceTest.php @@ -8,7 +8,6 @@ namespace Drupal\comment\Tests; use Drupal\Component\Utility\Xss; -use Drupal\Core\Language\Language; /** * Tests comment token replacement in strings. @@ -63,8 +62,8 @@ function testCommentTokenReplacement() { $tests['[comment:body]'] = $comment->comment_body->processed; $tests['[comment:url]'] = url('comment/' . $comment->id(), $url_options + array('fragment' => 'comment-' . $comment->id())); $tests['[comment:edit-url]'] = url('comment/' . $comment->id() . '/edit', $url_options); - $tests['[comment:created:since]'] = format_interval(REQUEST_TIME - $comment->getCreatedTime(), 2, $language_interface->id); - $tests['[comment:changed:since]'] = format_interval(REQUEST_TIME - $comment->getChangedTime(), 2, $language_interface->id); + $tests['[comment:created:since]'] = format_interval(REQUEST_TIME - $comment->getCreatedTime(), 2, $language_interface->getId()); + $tests['[comment:changed:since]'] = format_interval(REQUEST_TIME - $comment->getChangedTime(), 2, $language_interface->getId()); $tests['[comment:parent:cid]'] = $comment->hasParentComment() ? $comment->getParentComment()->id() : NULL; $tests['[comment:parent:title]'] = check_plain($parent_comment->getSubject()); $tests['[comment:node:nid]'] = $comment->getCommentedEntityId(); @@ -76,7 +75,7 @@ function testCommentTokenReplacement() { $this->assertFalse(in_array(0, array_map('strlen', $tests)), 'No empty tokens generated.'); foreach ($tests as $input => $expected) { - $output = $token_service->replace($input, array('comment' => $comment), array('langcode' => $language_interface->id)); + $output = $token_service->replace($input, array('comment' => $comment), array('langcode' => $language_interface->getId())); $this->assertEqual($output, $expected, format_string('Sanitized comment token %token replaced.', array('%token' => $input))); } @@ -93,7 +92,7 @@ function testCommentTokenReplacement() { $tests['[comment:author:name]'] = $this->admin_user->getUsername(); foreach ($tests as $input => $expected) { - $output = $token_service->replace($input, array('comment' => $comment), array('langcode' => $language_interface->id, 'sanitize' => FALSE)); + $output = $token_service->replace($input, array('comment' => $comment), array('langcode' => $language_interface->getId(), 'sanitize' => FALSE)); $this->assertEqual($output, $expected, format_string('Unsanitized comment token %token replaced.', array('%token' => $input))); } @@ -108,7 +107,7 @@ function testCommentTokenReplacement() { $tests['[node:comment-count]'] = 2; foreach ($tests as $input => $expected) { - $output = $token_service->replace($input, array('entity' => $node, 'node' => $node), array('langcode' => $language_interface->id)); + $output = $token_service->replace($input, array('entity' => $node, 'node' => $node), array('langcode' => $language_interface->getId())); $this->assertEqual($output, $expected, format_string('Node comment token %token replaced.', array('%token' => $input))); } } diff --git a/core/modules/config/lib/Drupal/config/Tests/ConfigEntityTest.php b/core/modules/config/lib/Drupal/config/Tests/ConfigEntityTest.php index f3ca94f..ba1bffe 100644 --- a/core/modules/config/lib/Drupal/config/Tests/ConfigEntityTest.php +++ b/core/modules/config/lib/Drupal/config/Tests/ConfigEntityTest.php @@ -12,7 +12,6 @@ use Drupal\Core\Entity\EntityStorageException; use Drupal\Core\Config\Entity\ConfigEntityStorage; use Drupal\Core\Config\Entity\Exception\ConfigEntityIdLengthException; -use Drupal\Core\Language\Language; use Drupal\simpletest\WebTestBase; /** @@ -44,7 +43,7 @@ public static function getInfo() { * Tests CRUD operations. */ function testCRUD() { - $default_langcode = \Drupal::languageManager()->getDefaultLanguage()->id; + $default_langcode = \Drupal::languageManager()->getDefaultLanguage()->getId(); // Verify default properties on a newly created empty entity. $empty = entity_create('config_test'); $this->assertIdentical($empty->id, NULL); diff --git a/core/modules/config/lib/Drupal/config/Tests/ConfigImportUITest.php b/core/modules/config/lib/Drupal/config/Tests/ConfigImportUITest.php index b95a666..88c4a13 100644 --- a/core/modules/config/lib/Drupal/config/Tests/ConfigImportUITest.php +++ b/core/modules/config/lib/Drupal/config/Tests/ConfigImportUITest.php @@ -63,7 +63,7 @@ function testImport() { 'test_dependencies' => array(), 'status' => TRUE, 'uuid' => '30df59bd-7b03-4cf7-bb35-d42fc49f0651', - 'langcode' => \Drupal::languageManager()->getDefaultLanguage()->id, + 'langcode' => \Drupal::languageManager()->getDefaultLanguage()->getId(), 'dependencies' => array(), 'protected_property' => '', ); diff --git a/core/modules/config/lib/Drupal/config/Tests/ConfigImporterTest.php b/core/modules/config/lib/Drupal/config/Tests/ConfigImporterTest.php index 21ce402..07f4da4 100644 --- a/core/modules/config/lib/Drupal/config/Tests/ConfigImporterTest.php +++ b/core/modules/config/lib/Drupal/config/Tests/ConfigImporterTest.php @@ -177,7 +177,7 @@ function testNew() { 'test_dependencies' => array(), 'status' => TRUE, 'uuid' => '30df59bd-7b03-4cf7-bb35-d42fc49f0651', - 'langcode' => \Drupal::languageManager()->getDefaultLanguage()->id, + 'langcode' => \Drupal::languageManager()->getDefaultLanguage()->getId(), 'dependencies' => array(), 'protected_property' => '', ); diff --git a/core/modules/config/lib/Drupal/config/Tests/ConfigLanguageOverrideWebTest.php b/core/modules/config/lib/Drupal/config/Tests/ConfigLanguageOverrideWebTest.php index 34f5172..5ac458a 100644 --- a/core/modules/config/lib/Drupal/config/Tests/ConfigLanguageOverrideWebTest.php +++ b/core/modules/config/lib/Drupal/config/Tests/ConfigLanguageOverrideWebTest.php @@ -72,7 +72,7 @@ function testSiteNameTranslation() { $language_manager = \Drupal::languageManager()->reset(); $this->assertTrue($language_manager->isMultilingual(), 'The test site is multilingual.'); $language = \Drupal::languageManager()->getLanguage('xx'); - $language->default = TRUE; + $language->setDefault(TRUE); language_save($language); language_delete('en'); $this->assertFalse($language_manager->isMultilingual(), 'The test site is monolingual.'); diff --git a/core/modules/config/lib/Drupal/config/Tests/ConfigOverridesPriorityTest.php b/core/modules/config/lib/Drupal/config/Tests/ConfigOverridesPriorityTest.php index 6deab96..d294514 100644 --- a/core/modules/config/lib/Drupal/config/Tests/ConfigOverridesPriorityTest.php +++ b/core/modules/config/lib/Drupal/config/Tests/ConfigOverridesPriorityTest.php @@ -61,7 +61,7 @@ public function testOverridePriorities() { )); \Drupal::languageManager()->setConfigOverrideLanguage($language); \Drupal::languageManager() - ->getLanguageConfigOverride($language->id, 'system.site') + ->getLanguageConfigOverride($language->getId(), 'system.site') ->set('name', $language_overridden_name) ->set('mail', $language_overridden_mail) ->save(); diff --git a/core/modules/config/tests/config_test/lib/Drupal/config_test/ConfigTestAccessController.php b/core/modules/config/tests/config_test/lib/Drupal/config_test/ConfigTestAccessController.php index cec5421..fee7966 100644 --- a/core/modules/config/tests/config_test/lib/Drupal/config_test/ConfigTestAccessController.php +++ b/core/modules/config/tests/config_test/lib/Drupal/config_test/ConfigTestAccessController.php @@ -10,7 +10,6 @@ use Drupal\Core\Session\AccountInterface; use Drupal\Core\Entity\EntityAccessController; use Drupal\Core\Entity\EntityInterface; -use Drupal\Core\Language\Language; /** * Defines the access controller for the config_test entity type. diff --git a/core/modules/config_translation/lib/Drupal/config_translation/Access/ConfigTranslationFormAccess.php b/core/modules/config_translation/lib/Drupal/config_translation/Access/ConfigTranslationFormAccess.php index 10c5f25..da2d2bc 100644 --- a/core/modules/config_translation/lib/Drupal/config_translation/Access/ConfigTranslationFormAccess.php +++ b/core/modules/config_translation/lib/Drupal/config_translation/Access/ConfigTranslationFormAccess.php @@ -32,8 +32,8 @@ public function access(Route $route, Request $request, AccountInterface $account // that is logically not a good idea. $access = !empty($target_language) && - !$target_language->locked && - $target_language->id != $this->sourceLanguage->id; + !$target_language->isLocked() && + $target_language->getId() != $this->sourceLanguage->getId(); return $access ? static::ALLOW : static::DENY; } diff --git a/core/modules/config_translation/lib/Drupal/config_translation/Access/ConfigTranslationOverviewAccess.php b/core/modules/config_translation/lib/Drupal/config_translation/Access/ConfigTranslationOverviewAccess.php index 1eef1ff..868733a 100644 --- a/core/modules/config_translation/lib/Drupal/config_translation/Access/ConfigTranslationOverviewAccess.php +++ b/core/modules/config_translation/lib/Drupal/config_translation/Access/ConfigTranslationOverviewAccess.php @@ -69,7 +69,7 @@ public function access(Route $route, Request $request, AccountInterface $account $account->hasPermission('translate configuration') && $mapper->hasSchema() && $mapper->hasTranslatable() && - !$this->sourceLanguage->locked; + !$this->sourceLanguage->isLocked(); return $access ? static::ALLOW : static::DENY; } diff --git a/core/modules/config_translation/lib/Drupal/config_translation/ConfigMapperInterface.php b/core/modules/config_translation/lib/Drupal/config_translation/ConfigMapperInterface.php index 28fb744..d12e7d0 100644 --- a/core/modules/config_translation/lib/Drupal/config_translation/ConfigMapperInterface.php +++ b/core/modules/config_translation/lib/Drupal/config_translation/ConfigMapperInterface.php @@ -7,7 +7,7 @@ namespace Drupal\config_translation; -use Drupal\Core\Language\Language; +use Drupal\Core\Language\LanguageInterface; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\Routing\RouteCollection; @@ -269,14 +269,14 @@ public function hasTranslatable(); /** * Checks whether there is already a translation for this mapper. * - * @param \Drupal\Core\Language\Language $language + * @param \Drupal\Core\Language\LanguageInterface $language * A language object. * * @return bool * TRUE if any of the configuration elements have a translation in the * given language, FALSE otherwise. */ - public function hasTranslation(Language $language); + public function hasTranslation(LanguageInterface $language); /** * Populate the config mapper with request data. diff --git a/core/modules/config_translation/lib/Drupal/config_translation/ConfigNamesMapper.php b/core/modules/config_translation/lib/Drupal/config_translation/ConfigNamesMapper.php index ce935f4..2e59b70 100644 --- a/core/modules/config_translation/lib/Drupal/config_translation/ConfigNamesMapper.php +++ b/core/modules/config_translation/lib/Drupal/config_translation/ConfigNamesMapper.php @@ -9,6 +9,7 @@ use Drupal\Core\Config\ConfigFactoryInterface; use Drupal\Core\Language\Language; +use Drupal\Core\Language\LanguageInterface; use Drupal\Core\Plugin\PluginBase; use Drupal\Core\Routing\RouteProviderInterface; use Drupal\Core\StringTranslation\TranslationInterface; @@ -432,7 +433,7 @@ public function hasTranslatable() { /** * {@inheritdoc} */ - public function hasTranslation(Language $language) { + public function hasTranslation(LanguageInterface $language) { foreach ($this->getConfigNames() as $name) { if ($this->localeConfigManager->hasTranslation($name, $language)) { return TRUE; diff --git a/core/modules/config_translation/lib/Drupal/config_translation/Controller/ConfigTranslationController.php b/core/modules/config_translation/lib/Drupal/config_translation/Controller/ConfigTranslationController.php index 827b99e..f7d4f14 100644 --- a/core/modules/config_translation/lib/Drupal/config_translation/Controller/ConfigTranslationController.php +++ b/core/modules/config_translation/lib/Drupal/config_translation/Controller/ConfigTranslationController.php @@ -152,7 +152,7 @@ public function itemPage(Request $request, $plugin_id) { '#header' => array($this->t('Language'), $this->t('Operations')), ); foreach ($languages as $language) { - $langcode = $language->id; + $langcode = $language->getId(); // This is needed because // ConfigMapperInterface::getAddRouteParameters(), for example, @@ -163,7 +163,7 @@ public function itemPage(Request $request, $plugin_id) { // Prepare the language name and the operations depending on whether this // is the original language or not. if ($langcode == $original_langcode) { - $language_name = '' . $this->t('@language (original)', array('@language' => $language->name)) . ''; + $language_name = '' . $this->t('@language (original)', array('@language' => $language->getName())) . ''; // Check access for the path/route for editing, so we can decide to // include a link to edit or not. @@ -189,7 +189,7 @@ public function itemPage(Request $request, $plugin_id) { } } else { - $language_name = $language->name; + $language_name = $language->getName(); $operations = array(); // If no translation exists for this language, link to add one. diff --git a/core/modules/config_translation/lib/Drupal/config_translation/Form/ConfigTranslationAddForm.php b/core/modules/config_translation/lib/Drupal/config_translation/Form/ConfigTranslationAddForm.php index 9556be2..b7806d2 100644 --- a/core/modules/config_translation/lib/Drupal/config_translation/Form/ConfigTranslationAddForm.php +++ b/core/modules/config_translation/lib/Drupal/config_translation/Form/ConfigTranslationAddForm.php @@ -28,7 +28,7 @@ public function buildForm(array $form, array &$form_state, Request $request = NU $form = parent::buildForm($form, $form_state, $request, $plugin_id, $langcode); $form['#title'] = $this->t('Add @language translation for %label', array( '%label' => $this->mapper->getTitle(), - '@language' => $this->language->name, + '@language' => $this->language->getName(), )); return $form; } @@ -38,7 +38,7 @@ public function buildForm(array $form, array &$form_state, Request $request = NU */ public function submitForm(array &$form, array &$form_state) { parent::submitForm($form, $form_state); - drupal_set_message($this->t('Successfully saved @language translation.', array('@language' => $this->language->name))); + drupal_set_message($this->t('Successfully saved @language translation.', array('@language' => $this->language->getName()))); } } diff --git a/core/modules/config_translation/lib/Drupal/config_translation/Form/ConfigTranslationDeleteForm.php b/core/modules/config_translation/lib/Drupal/config_translation/Form/ConfigTranslationDeleteForm.php index f7f9b2e..cacebdf 100644 --- a/core/modules/config_translation/lib/Drupal/config_translation/Form/ConfigTranslationDeleteForm.php +++ b/core/modules/config_translation/lib/Drupal/config_translation/Form/ConfigTranslationDeleteForm.php @@ -87,7 +87,7 @@ public static function create(ContainerInterface $container) { * {@inheritdoc} */ public function getQuestion() { - return $this->t('Are you sure you want to delete the @language translation of %label?', array('%label' => $this->mapper->getTitle(), '@language' => $this->language->name)); + return $this->t('Are you sure you want to delete the @language translation of %label?', array('%label' => $this->mapper->getTitle(), '@language' => $this->language->getName())); } /** @@ -137,7 +137,7 @@ public function buildForm(array $form, array &$form_state, Request $request = NU */ public function submitForm(array &$form, array &$form_state) { foreach ($this->mapper->getConfigNames() as $name) { - $this->languageManager->getLanguageConfigOverride($this->language->id, $name)->delete(); + $this->languageManager->getLanguageConfigOverride($this->language->getId(), $name)->delete(); } // Flush all persistent caches. @@ -146,7 +146,7 @@ public function submitForm(array &$form, array &$form_state) { $cache_backend->deleteAll(); } - drupal_set_message($this->t('@language translation of %label was deleted', array('%label' => $this->mapper->getTitle(), '@language' => $this->language->name))); + drupal_set_message($this->t('@language translation of %label was deleted', array('%label' => $this->mapper->getTitle(), '@language' => $this->language->getName()))); $form_state['redirect_route'] = array( 'route_name' => $this->mapper->getOverviewRoute(), diff --git a/core/modules/config_translation/lib/Drupal/config_translation/Form/ConfigTranslationEditForm.php b/core/modules/config_translation/lib/Drupal/config_translation/Form/ConfigTranslationEditForm.php index 565d07a..23c5a71 100644 --- a/core/modules/config_translation/lib/Drupal/config_translation/Form/ConfigTranslationEditForm.php +++ b/core/modules/config_translation/lib/Drupal/config_translation/Form/ConfigTranslationEditForm.php @@ -28,7 +28,7 @@ public function buildForm(array $form, array &$form_state, Request $request = NU $form = parent::buildForm($form, $form_state, $request, $plugin_id, $langcode); $form['#title'] = $this->t('Edit @language translation for %label', array( '%label' => $this->mapper->getTitle(), - '@language' => $this->language->name, + '@language' => $this->language->getName(), )); return $form; } @@ -38,7 +38,7 @@ public function buildForm(array $form, array &$form_state, Request $request = NU */ public function submitForm(array &$form, array &$form_state) { parent::submitForm($form, $form_state); - drupal_set_message($this->t('Successfully updated @language translation.', array('@language' => $this->language->name))); + drupal_set_message($this->t('Successfully updated @language translation.', array('@language' => $this->language->getName()))); } } diff --git a/core/modules/config_translation/lib/Drupal/config_translation/Form/ConfigTranslationFormBase.php b/core/modules/config_translation/lib/Drupal/config_translation/Form/ConfigTranslationFormBase.php index fb3ba88..fa81fe4 100644 --- a/core/modules/config_translation/lib/Drupal/config_translation/Form/ConfigTranslationFormBase.php +++ b/core/modules/config_translation/lib/Drupal/config_translation/Form/ConfigTranslationFormBase.php @@ -14,7 +14,7 @@ use Drupal\Core\Extension\ModuleHandlerInterface; use Drupal\Core\Form\BaseFormIdInterface; use Drupal\Core\Form\FormBase; -use Drupal\Core\Language\Language; +use Drupal\Core\Language\LanguageInterface; use Drupal\language\ConfigurableLanguageManagerInterface; use Drupal\locale\StringStorageInterface; use Symfony\Component\DependencyInjection\ContainerInterface; @@ -224,7 +224,7 @@ public function submitForm(array &$form, array &$form_state) { foreach ($this->mapper->getConfigNames() as $name) { // Set configuration values based on form submission and source values. $base_config = $config_factory->get($name); - $config_translation = $this->languageManager->getLanguageConfigOverride($this->language->id, $name); + $config_translation = $this->languageManager->getLanguageConfigOverride($this->language->getId(), $name); $locations = $this->localeStorage->getLocations(array('type' => 'configuration', 'name' => $name)); $this->setConfig($this->language, $base_config, $config_translation, $form_values[$name], !empty($locations)); @@ -324,12 +324,12 @@ protected function buildConfigForm(Element $schema, $config_data, $base_config_d '#theme' => 'config_translation_manage_form_element', ); $build[$element_key]['source'] = array( - '#markup' => $base_config_data[$key] ? ('' . nl2br($base_config_data[$key] . '')) : t('(Empty)'), + '#markup' => $base_config_data[$key] ? ('' . nl2br($base_config_data[$key] . '')) : t('(Empty)'), '#title' => $this->t( '!label (!source_language)', array( '!label' => $this->t($definition['label']), - '!source_language' => $this->sourceLanguage->name, + '!source_language' => $this->sourceLanguage->getName(), ) ), '#type' => 'item', @@ -348,7 +348,7 @@ protected function buildConfigForm(Element $schema, $config_data, $base_config_d /** * Sets configuration based on a nested form value array. * - * @param \Drupal\Core\Language\Language $language + * @param \Drupal\Core\Language\LanguageInterface $language * Set the configuration in this language. * @param \Drupal\Core\Config\Config $base_config * Base configuration values, in the source language. @@ -372,7 +372,7 @@ protected function buildConfigForm(Element $schema, $config_data, $base_config_d * @return array * Translation configuration override data. */ - protected function setConfig(Language $language, Config $base_config, Config $config_translation, array $config_values, $shipped_config = FALSE) { + protected function setConfig(LanguageInterface $language, Config $base_config, Config $config_translation, array $config_values, $shipped_config = FALSE) { foreach ($config_values as $key => $value) { if (is_array($value) && !isset($value['translation'])) { // Traverse into this level in the configuration. @@ -388,7 +388,7 @@ protected function setConfig(Language $language, Config $base_config, Config $co // Get the translation for this original source string from locale. $conditions = array( 'lid' => $source_string->lid, - 'language' => $language->id, + 'language' => $language->getId(), ); $translations = $this->localeStorage->getTranslations($conditions + array('translated' => TRUE)); // If we got a translation, take that, otherwise create a new one. diff --git a/core/modules/config_translation/lib/Drupal/config_translation/FormElement/DateFormat.php b/core/modules/config_translation/lib/Drupal/config_translation/FormElement/DateFormat.php index 3abb57e..64f4d68 100644 --- a/core/modules/config_translation/lib/Drupal/config_translation/FormElement/DateFormat.php +++ b/core/modules/config_translation/lib/Drupal/config_translation/FormElement/DateFormat.php @@ -10,7 +10,7 @@ use Drupal\Component\Utility\NestedArray; use Drupal\Core\Ajax\AjaxResponse; use Drupal\Core\Ajax\ReplaceCommand; -use Drupal\Core\Language\Language; +use Drupal\Core\Language\LanguageInterface; use Drupal\Core\StringTranslation\StringTranslationTrait; /** @@ -22,7 +22,7 @@ class DateFormat implements ElementInterface { /** * {@inheritdoc} */ - public function getFormElement(array $definition, Language $language, $value) { + public function getFormElement(array $definition, LanguageInterface $language, $value) { if (class_exists('intlDateFormatter')) { $description = $this->t('A user-defined date format. See the PHP manual for available options.', array('@url' => 'http://userguide.icu-project.org/formatparse/datetime')); } @@ -32,10 +32,10 @@ public function getFormElement(array $definition, Language $language, $value) { $format = $this->t('Displayed as %date_format', array('%date_format' => \Drupal::service('date')->format(REQUEST_TIME, 'custom', $value))); return array( '#type' => 'textfield', - '#title' => $this->t($definition['label']) . ' (' . $language->name . ')', + '#title' => $this->t($definition['label']) . ' (' . $language->getName() . ')', '#description' => $description, '#default_value' => $value, - '#attributes' => array('lang' => $language->id), + '#attributes' => array('lang' => $language->getId()), '#field_suffix' => '
' . $format . '
', '#ajax' => array( 'callback' => 'Drupal\config_translation\FormElement\DateFormat::ajaxSample', diff --git a/core/modules/config_translation/lib/Drupal/config_translation/FormElement/ElementInterface.php b/core/modules/config_translation/lib/Drupal/config_translation/FormElement/ElementInterface.php index 9072cfc..ecc93f0 100644 --- a/core/modules/config_translation/lib/Drupal/config_translation/FormElement/ElementInterface.php +++ b/core/modules/config_translation/lib/Drupal/config_translation/FormElement/ElementInterface.php @@ -7,7 +7,7 @@ namespace Drupal\config_translation\FormElement; -use Drupal\Core\Language\Language; +use Drupal\Core\Language\LanguageInterface; /** * Provides an interface for configuration translation form elements. @@ -19,7 +19,7 @@ * * @param array $definition * Configuration schema type definition of the element. - * @param \Drupal\Core\Language\Language $language + * @param \Drupal\Core\Language\LanguageInterface $language * Language object to display the translation form for. * @param string $value * Default value for the form element. @@ -27,6 +27,6 @@ * @return array * Form API array to represent the form element. */ - public function getFormElement(array $definition, Language $language, $value); + public function getFormElement(array $definition, LanguageInterface $language, $value); } diff --git a/core/modules/config_translation/lib/Drupal/config_translation/FormElement/Textarea.php b/core/modules/config_translation/lib/Drupal/config_translation/FormElement/Textarea.php index b796685..5f20e5c 100644 --- a/core/modules/config_translation/lib/Drupal/config_translation/FormElement/Textarea.php +++ b/core/modules/config_translation/lib/Drupal/config_translation/FormElement/Textarea.php @@ -7,7 +7,7 @@ namespace Drupal\config_translation\FormElement; -use Drupal\Core\Language\Language; +use Drupal\Core\Language\LanguageInterface; use Drupal\Core\StringTranslation\StringTranslationTrait; /** @@ -19,7 +19,7 @@ class Textarea implements ElementInterface { /** * {@inheritdoc} */ - public function getFormElement(array $definition, Language $language, $value) { + public function getFormElement(array $definition, LanguageInterface $language, $value) { // Estimate a comfortable size of the input textarea. $rows_words = ceil(str_word_count($value) / 5); $rows_newlines = substr_count($value, "\n" ) + 1; @@ -28,9 +28,9 @@ public function getFormElement(array $definition, Language $language, $value) { return array( '#type' => 'textarea', '#default_value' => $value, - '#title' => $this->t($definition['label']) . ' (' . $language->name . ')', + '#title' => $this->t($definition['label']) . ' (' . $language->getName() . ')', '#rows' => $rows, - '#attributes' => array('lang' => $language->id), + '#attributes' => array('lang' => $language->getId()), ); } diff --git a/core/modules/config_translation/lib/Drupal/config_translation/FormElement/Textfield.php b/core/modules/config_translation/lib/Drupal/config_translation/FormElement/Textfield.php index 46d71fe..5905a7e 100644 --- a/core/modules/config_translation/lib/Drupal/config_translation/FormElement/Textfield.php +++ b/core/modules/config_translation/lib/Drupal/config_translation/FormElement/Textfield.php @@ -7,7 +7,7 @@ namespace Drupal\config_translation\FormElement; -use Drupal\Core\Language\Language; +use Drupal\Core\Language\LanguageInterface; use Drupal\Core\StringTranslation\StringTranslationTrait; /** @@ -19,12 +19,12 @@ class Textfield implements ElementInterface { /** * {@inheritdoc} */ - public function getFormElement(array $definition, Language $language, $value) { + public function getFormElement(array $definition, LanguageInterface $language, $value) { return array( '#type' => 'textfield', '#default_value' => $value, - '#title' => $this->t($definition['label']) . ' (' . $language->name . ')', - '#attributes' => array('lang' => $language->id), + '#title' => $this->t($definition['label']) . ' (' . $language->getName() . ')', + '#attributes' => array('lang' => $language->getId()), ); } diff --git a/core/modules/config_translation/lib/Drupal/config_translation/Tests/ConfigTranslationUiTest.php b/core/modules/config_translation/lib/Drupal/config_translation/Tests/ConfigTranslationUiTest.php index 46ef47f..5f2989c 100644 --- a/core/modules/config_translation/lib/Drupal/config_translation/Tests/ConfigTranslationUiTest.php +++ b/core/modules/config_translation/lib/Drupal/config_translation/Tests/ConfigTranslationUiTest.php @@ -11,6 +11,7 @@ use Drupal\Component\Utility\Unicode; use Drupal\Core\Config\FileStorage; use Drupal\Core\Language\Language; +use Drupal\Core\Language\LanguageInterface; use Drupal\simpletest\WebTestBase; /** @@ -330,7 +331,7 @@ public function testContactConfigEntityTranslation() { // Test that delete links work and operations perform properly. foreach ($this->langcodes as $langcode) { - $replacements = array('%label' => t('!label !entity_type', array('!label' => $label, '!entity_type' => Unicode::strtolower(t('Contact category')))), '@language' => language_load($langcode)->name); + $replacements = array('%label' => t('!label !entity_type', array('!label' => $label, '!entity_type' => Unicode::strtolower(t('Contact category')))), '@language' => language_load($langcode)->getName()); $this->drupalGet("$translation_base_url/$langcode/delete"); $this->assertRaw(t('Are you sure you want to delete the @language translation of %label?', $replacements)); @@ -494,7 +495,7 @@ public function testSourceAndTargetLanguage() { $this->container ->get('config.factory') ->get('system.site') - ->set('langcode', Language::LANGCODE_NOT_SPECIFIED) + ->set('langcode', LanguageInterface::LANGCODE_NOT_SPECIFIED) ->save(); // Make sure translation tab does not exist on the configuration page. diff --git a/core/modules/config_translation/tests/Drupal/config_translation/Tests/ConfigMapperManagerTest.php b/core/modules/config_translation/tests/Drupal/config_translation/Tests/ConfigMapperManagerTest.php index 860941b..dd51300 100644 --- a/core/modules/config_translation/tests/Drupal/config_translation/Tests/ConfigMapperManagerTest.php +++ b/core/modules/config_translation/tests/Drupal/config_translation/Tests/ConfigMapperManagerTest.php @@ -9,6 +9,7 @@ use Drupal\config_translation\ConfigMapperManager; use Drupal\Core\Language\Language; +use Drupal\Core\Language\LanguageInterface; use Drupal\Core\TypedData\TypedDataInterface; use Drupal\Tests\UnitTestCase; @@ -50,7 +51,7 @@ public function setUp() { $language_manager = $this->getMock('Drupal\Core\Language\LanguageManagerInterface'); $language_manager->expects($this->once()) ->method('getCurrentLanguage') - ->with(Language::TYPE_INTERFACE) + ->with(LanguageInterface::TYPE_INTERFACE) ->will($this->returnValue($language)); $this->typedConfigManager = $this->getMockBuilder('Drupal\Core\Config\TypedConfigManager') diff --git a/core/modules/contact/contact.install b/core/modules/contact/contact.install index 477f359..5fc97bc 100644 --- a/core/modules/contact/contact.install +++ b/core/modules/contact/contact.install @@ -5,8 +5,6 @@ * Install, update and uninstall functions for the contact module. */ -use Drupal\Core\Language\Language; - /** * Implements hook_install(). */ diff --git a/core/modules/contact/contact.module b/core/modules/contact/contact.module index fe37a2b..f55d787 100644 --- a/core/modules/contact/contact.module +++ b/core/modules/contact/contact.module @@ -151,14 +151,14 @@ function contact_mail($key, &$message, $params) { $variables['!sender-url'] = $params['sender']->getEmail(); } - $options = array('langcode' => $language->id); + $options = array('langcode' => $language->getId()); switch ($key) { case 'page_mail': case 'page_copy': $message['subject'] .= t('[!category] !subject', $variables, $options); $message['body'][] = t("!sender-name (!sender-url) sent a message using the contact form at !form-url.", $variables, $options); - $build = entity_view($contact_message, 'mail', $language->id); + $build = entity_view($contact_message, 'mail', $language->getId()); $message['body'][] = drupal_render($build); break; @@ -177,7 +177,7 @@ function contact_mail($key, &$message, $params) { $message['body'][] = t('Hello !recipient-name,', $variables, $options); $message['body'][] = t("!sender-name (!sender-url) has sent you a message via your contact form at !site-name.", $variables, $options); $message['body'][] = t("If you don't want to receive such e-mails, you can change your settings at !recipient-edit-url.", $variables, $options); - $build = entity_view($contact_message, 'mail', $language->id); + $build = entity_view($contact_message, 'mail', $language->getId()); $message['body'][] = drupal_render($build); break; } diff --git a/core/modules/contact/lib/Drupal/contact/MessageForm.php b/core/modules/contact/lib/Drupal/contact/MessageForm.php index 401291e..c5a3683 100644 --- a/core/modules/contact/lib/Drupal/contact/MessageForm.php +++ b/core/modules/contact/lib/Drupal/contact/MessageForm.php @@ -11,7 +11,6 @@ use Drupal\Core\Entity\ContentEntityForm; use Drupal\Core\Entity\EntityManagerInterface; use Drupal\Core\Flood\FloodInterface; -use Drupal\Core\Language\Language; use Drupal\user\UserInterface; use Symfony\Component\DependencyInjection\ContainerInterface; @@ -200,7 +199,7 @@ public function save(array $form, array &$form_state) { $params['contact_category'] = $category; $to = implode(', ', $category->recipients); - $recipient_langcode = language_default()->id; + $recipient_langcode = language_default()->getId(); } elseif ($recipient = $message->getPersonalRecipient()) { // Send to the user in the user's preferred language. @@ -218,14 +217,14 @@ public function save(array $form, array &$form_state) { // If requested, send a copy to the user, using the current language. if ($message->copySender()) { - drupal_mail('contact', $key_prefix . '_copy', $sender->getEmail(), $language_interface->id, $params, $sender->getEmail()); + drupal_mail('contact', $key_prefix . '_copy', $sender->getEmail(), $language_interface->getId(), $params, $sender->getEmail()); } // If configured, send an auto-reply, using the current language. if (!$message->isPersonal() && $category->reply) { // User contact forms do not support an auto-reply message, so this // message always originates from the site. - drupal_mail('contact', 'page_autoreply', $sender->getEmail(), $language_interface->id, $params); + drupal_mail('contact', 'page_autoreply', $sender->getEmail(), $language_interface->getId(), $params); } $config = $this->config('contact.settings'); diff --git a/core/modules/contact/lib/Drupal/contact/Tests/ContactSitewideTest.php b/core/modules/contact/lib/Drupal/contact/Tests/ContactSitewideTest.php index 7813678..583d650 100644 --- a/core/modules/contact/lib/Drupal/contact/Tests/ContactSitewideTest.php +++ b/core/modules/contact/lib/Drupal/contact/Tests/ContactSitewideTest.php @@ -124,7 +124,7 @@ function testSiteWideContact() { // Check that the category was created in site default language. $langcode = \Drupal::config('contact.category.' . $id)->get('langcode'); - $default_langcode = \Drupal::languageManager()->getDefaultLanguage()->id; + $default_langcode = \Drupal::languageManager()->getDefaultLanguage()->getId(); $this->assertEqual($langcode, $default_langcode); // Make sure the newly created category is included in the list of categories. diff --git a/core/modules/content_translation/content_translation.admin.inc b/core/modules/content_translation/content_translation.admin.inc index eb03aea..9f018e9 100644 --- a/core/modules/content_translation/content_translation.admin.inc +++ b/core/modules/content_translation/content_translation.admin.inc @@ -7,7 +7,7 @@ use Drupal\Component\Utility\String; use Drupal\Core\Field\FieldDefinitionInterface; -use Drupal\Core\Language\Language; +use Drupal\Core\Language\LanguageInterface; use Drupal\Core\Render\Element; use Drupal\field\Entity\FieldConfig; use Drupal\field\FieldInstanceConfigInterface; @@ -278,8 +278,8 @@ function content_translation_form_language_content_settings_validate(array $form $values = $bundle_settings['settings']['language']; if (empty($values['language_show']) && \Drupal::languageManager()->isLanguageLocked($values['langcode'])) { - foreach (\Drupal::languageManager()->getLanguages(Language::STATE_LOCKED) as $language) { - $locked_languages[] = $language->name; + foreach (\Drupal::languageManager()->getLanguages(LanguageInterface::STATE_LOCKED) as $language) { + $locked_languages[] = $language->getName(); } form_set_error($name, $form_state, t('Translation is not supported if language is always one of: @locked_languages', array('@locked_languages' => implode(', ', $locked_languages)))); } diff --git a/core/modules/content_translation/content_translation.install b/core/modules/content_translation/content_translation.install index f6dda75..383d043 100644 --- a/core/modules/content_translation/content_translation.install +++ b/core/modules/content_translation/content_translation.install @@ -6,7 +6,7 @@ */ use Drupal\Core\Entity\EntityTypeInterface; -use Drupal\Core\Language\Language; +use Drupal\Core\Language\LanguageInterface; use Drupal\language\Plugin\LanguageNegotiation\LanguageNegotiationUrl; /** @@ -87,7 +87,7 @@ function content_translation_install() { // Assign a fairly low weight to ensure our implementation of // hook_module_implements_alter() is run among the last ones. module_set_weight('content_translation', 10); - \Drupal::service('language_negotiator')->saveConfiguration(Language::TYPE_CONTENT, array(LanguageNegotiationUrl::METHOD_ID => 0)); + \Drupal::service('language_negotiator')->saveConfiguration(LanguageInterface::TYPE_CONTENT, array(LanguageNegotiationUrl::METHOD_ID => 0)); $config_names = \Drupal::configFactory()->listAll('field.field.'); foreach ($config_names as $name) { diff --git a/core/modules/content_translation/content_translation.module b/core/modules/content_translation/content_translation.module index 502d4e4..a7be087 100644 --- a/core/modules/content_translation/content_translation.module +++ b/core/modules/content_translation/content_translation.module @@ -11,7 +11,7 @@ use Drupal\Core\Entity\EntityInterface; use Drupal\Core\Entity\EntityTypeInterface; use Drupal\Core\Field\FieldDefinition; -use Drupal\Core\Language\Language; +use Drupal\Core\Language\LanguageInterface; use Drupal\Core\Session\AccountInterface; use Drupal\Core\TypedData\TranslatableInterface; use Drupal\field\Entity\FieldInstanceConfig; @@ -72,8 +72,8 @@ function content_translation_module_implements_alter(&$implementations, $hook) { function content_translation_language_types_info_alter(array &$language_types) { // Make content language negotiation configurable by removing the 'locked' // flag. - $language_types[Language::TYPE_CONTENT]['locked'] = FALSE; - unset($language_types[Language::TYPE_CONTENT]['fixed']); + $language_types[LanguageInterface::TYPE_CONTENT]['locked'] = FALSE; + unset($language_types[LanguageInterface::TYPE_CONTENT]['fixed']); } /** @@ -711,7 +711,7 @@ function content_translation_entity_presave(EntityInterface $entity) { // @todo Avoid using request attributes once translation metadata become // regular fields. $attributes = \Drupal::request()->attributes; - \Drupal::service('content_translation.synchronizer')->synchronizeFields($entity, $entity->language()->id, $attributes->get('source_langcode')); + \Drupal::service('content_translation.synchronizer')->synchronizeFields($entity, $entity->language()->getId(), $attributes->get('source_langcode')); } } @@ -792,8 +792,8 @@ function content_translation_language_configuration_element_validate($element, a $key = $form_state['content_translation']['key']; $values = $form_state['values'][$key]; if (!$values['language_show'] && $values['content_translation'] && \Drupal::languageManager()->isLanguageLocked($values['langcode'])) { - foreach (\Drupal::languageManager()->getLanguages(Language::STATE_LOCKED) as $language) { - $locked_languages[] = $language->name; + foreach (\Drupal::languageManager()->getLanguages(LanguageInterface::STATE_LOCKED) as $language) { + $locked_languages[] = $language->getName(); } // @todo Set the correct form element name as soon as the element parents // are correctly set. We should be using NestedArray::getValue() but for diff --git a/core/modules/content_translation/content_translation.pages.inc b/core/modules/content_translation/content_translation.pages.inc index d4a7c48..3240fe9 100644 --- a/core/modules/content_translation/content_translation.pages.inc +++ b/core/modules/content_translation/content_translation.pages.inc @@ -5,7 +5,7 @@ * The content translation user interface. */ -use Drupal\Core\Language\Language; +use Drupal\Core\Language\LanguageInterface; use Drupal\Core\Entity\EntityInterface; use Drupal\Core\Entity\ContentEntityInterface; @@ -21,7 +21,7 @@ function content_translation_overview(EntityInterface $entity) { $controller = content_translation_controller($entity->getEntityTypeId()); $languages = \Drupal::languageManager()->getLanguages(); - $original = $entity->getUntranslated()->language()->id; + $original = $entity->getUntranslated()->language()->getId(); $translations = $entity->getTranslationLanguages(); $administrator = \Drupal::currentUser()->hasPermission('administer languages'); @@ -50,8 +50,8 @@ function content_translation_overview(EntityInterface $entity) { $show_source_column = !empty($additional_source_langcodes); foreach ($languages as $language) { - $language_name = $language->name; - $langcode = $language->id; + $language_name = $language->getName(); + $langcode = $language->getId(); $add_path = $rel['drupal:content-translation-overview'] . '/add/' . $original . '/' . $langcode; $translate_path = $rel['drupal:content-translation-overview'] . '/edit/' . $langcode; @@ -105,7 +105,7 @@ function content_translation_overview(EntityInterface $entity) { $source_name = t('n/a'); } else { - $source_name = isset($languages[$source]) ? $languages[$source]->name : t('n/a'); + $source_name = isset($languages[$source]) ? $languages[$source]->getName() : t('n/a'); if ($controller->getTranslationAccess($entity, 'delete')) { $links['delete'] = isset($delete_links->links[$langcode]['href']) ? $delete_links->links[$langcode] : array('href' => $delete_links, 'language' => $language); $links['delete']['title'] = t('Delete'); @@ -115,7 +115,7 @@ function content_translation_overview(EntityInterface $entity) { else { // No such translation in the set yet: help user to create it. $row_title = $source_name = t('n/a'); - $source = $entity->language()->id; + $source = $entity->language()->getId(); if ($source != $langcode && $controller->getTranslationAccess($entity, 'create')) { if ($translatable) { @@ -171,12 +171,13 @@ function content_translation_overview(EntityInterface $entity) { * A renderable array of language switch links. */ function _content_translation_get_switch_links($path) { - $links = \Drupal::languageManager()->getLanguageSwitchLinks(Language::TYPE_CONTENT, $path); + $links = \Drupal::languageManager()->getLanguageSwitchLinks(LanguageInterface::TYPE_CONTENT, $path); if (empty($links)) { // If content language is set up to fall back to the interface language, - // then there will be no switch links for Language::TYPE_CONTENT, ergo we - // also need to use interface switch links. - $links = \Drupal::languageManager()->getLanguageSwitchLinks(Language::TYPE_INTERFACE, $path); + // then there will be no switch links for + // \Drupal\Core\Language\LanguageInterface::TYPE_CONTENT, ergo we also need + // to use interface switch links. + $links = \Drupal::languageManager()->getLanguageSwitchLinks(LanguageInterface::TYPE_INTERFACE, $path); } return $links; } @@ -186,10 +187,10 @@ function _content_translation_get_switch_links($path) { * * @param EntityInterface $entity * The entity being translated. - * @param Language $source + * @param \Drupal\Core\Language\LanguageInterface $source * (optional) The language of the values being translated. Defaults to the * entity language. - * @param Language $target + * @param \Drupal\Core\Language\LanguageInterface $target * (optional) The language of the translated values. Defaults to the current * content language. * @@ -199,12 +200,12 @@ function _content_translation_get_switch_links($path) { * @deprecated in Drupal 8.x-dev, will be removed before Drupal 8.0. * Use \Drupal\content_translation\Controller\ContentTranslationController::add(). */ -function content_translation_add_page(EntityInterface $entity, Language $source = NULL, Language $target = NULL) { +function content_translation_add_page(EntityInterface $entity, LanguageInterface $source = NULL, LanguageInterface $target = NULL) { $source = !empty($source) ? $source : $entity->language(); - $target = !empty($target) ? $target : \Drupal::languageManager()->getCurrentLanguage(Language::TYPE_CONTENT); + $target = !empty($target) ? $target : \Drupal::languageManager()->getCurrentLanguage(LanguageInterface::TYPE_CONTENT); // @todo Exploit the upcoming hook_entity_prepare() when available. content_translation_prepare_translation($entity, $source, $target); - $form_state['langcode'] = $target->id; + $form_state['langcode'] = $target->getId(); $form_state['content_translation']['source'] = $source; $form_state['content_translation']['target'] = $target; $form_state['content_translation']['translation_form'] = !$entity->access('update'); @@ -216,7 +217,7 @@ function content_translation_add_page(EntityInterface $entity, Language $source * * @param \Drupal\Core\Entity\EntityInterface $entity * The entity being translated. - * @param \Drupal\Core\Language\Language $language + * @param \Drupal\Core\Language\LanguageInterface $language * (optional) The language of the translated values. Defaults to the current * content language. * @@ -226,9 +227,9 @@ function content_translation_add_page(EntityInterface $entity, Language $source * @deprecated in Drupal 8.x-dev, will be removed before Drupal 8.0. * Use \Drupal\content_translation\Controller\ContentTranslationController::edit(). */ -function content_translation_edit_page(EntityInterface $entity, Language $language = NULL) { - $language = !empty($language) ? $language : \Drupal::languageManager()->getCurrentLanguage(Language::TYPE_CONTENT); - $form_state['langcode'] = $language->id; +function content_translation_edit_page(EntityInterface $entity, LanguageInterface $language = NULL) { + $language = !empty($language) ? $language : \Drupal::languageManager()->getCurrentLanguage(LanguageInterface::TYPE_CONTENT); + $form_state['langcode'] = $language->getId(); $form_state['content_translation']['translation_form'] = TRUE; return \Drupal::service('entity.form_builder')->getForm($entity, 'default', $form_state); } @@ -238,14 +239,14 @@ function content_translation_edit_page(EntityInterface $entity, Language $langua * * @param \Drupal\Core\Entity\EntityInterface $entity * The entitiy being translated. - * @param \Drupal\Core\Language\Language $source + * @param \Drupal\Core\Language\LanguageInterface $source * The language to be used as source. - * @param \Drupal\Core\Language\Language $target + * @param \Drupal\Core\Language\LanguageInterface $target * The language to be used as target. */ -function content_translation_prepare_translation(EntityInterface $entity, Language $source, Language $target) { +function content_translation_prepare_translation(EntityInterface $entity, LanguageInterface $source, LanguageInterface $target) { if ($entity instanceof ContentEntityInterface) { - $source_translation = $entity->getTranslation($source->id); - $entity->addTranslation($target->id, $source_translation->toArray()); + $source_translation = $entity->getTranslation($source->getId()); + $entity->addTranslation($target->getId(), $source_translation->toArray()); } } diff --git a/core/modules/content_translation/lib/Drupal/content_translation/Access/ContentTranslationManageAccessCheck.php b/core/modules/content_translation/lib/Drupal/content_translation/Access/ContentTranslationManageAccessCheck.php index b0e0fb6..9faa3b0 100644 --- a/core/modules/content_translation/lib/Drupal/content_translation/Access/ContentTranslationManageAccessCheck.php +++ b/core/modules/content_translation/lib/Drupal/content_translation/Access/ContentTranslationManageAccessCheck.php @@ -8,7 +8,7 @@ namespace Drupal\content_translation\Access; use Drupal\Core\Entity\EntityManagerInterface; -use Drupal\Core\Language\Language; +use Drupal\Core\Language\LanguageInterface; use Drupal\Core\Routing\Access\AccessInterface; use Drupal\Core\Session\AccountInterface; use Symfony\Component\Routing\Route; @@ -70,20 +70,20 @@ public function access(Route $route, Request $request, AccountInterface $account switch ($operation) { case 'create': $source = language_load($source) ?: $entity->language(); - $target = language_load($target) ?: \Drupal::languageManager()->getCurrentLanguage(Language::TYPE_CONTENT); - return ($source->id != $target->id - && isset($languages[$source->id]) - && isset($languages[$target->id]) - && !isset($translations[$target->id]) + $target = language_load($target) ?: \Drupal::languageManager()->getCurrentLanguage(LanguageInterface::TYPE_CONTENT); + return ($source->getId() != $target->getId() + && isset($languages[$source->getId()]) + && isset($languages[$target->getId()]) + && !isset($translations[$target->getId()]) && $controller->getTranslationAccess($entity, $operation)) ? static::ALLOW : static::DENY; case 'update': case 'delete': - $language = language_load($language) ?: \Drupal::languageManager()->getCurrentLanguage(Language::TYPE_CONTENT); - return isset($languages[$language->id]) - && $language->id != $entity->getUntranslated()->language()->id - && isset($translations[$language->id]) + $language = language_load($language) ?: \Drupal::languageManager()->getCurrentLanguage(LanguageInterface::TYPE_CONTENT); + return isset($languages[$language->getId()]) + && $language->getId() != $entity->getUntranslated()->language()->getId() + && isset($translations[$language->getId()]) && $controller->getTranslationAccess($entity, $operation) ? static::ALLOW : static::DENY; } diff --git a/core/modules/content_translation/lib/Drupal/content_translation/ContentTranslationHandler.php b/core/modules/content_translation/lib/Drupal/content_translation/ContentTranslationHandler.php index 76723c2..3cd1361 100644 --- a/core/modules/content_translation/lib/Drupal/content_translation/ContentTranslationHandler.php +++ b/core/modules/content_translation/lib/Drupal/content_translation/ContentTranslationHandler.php @@ -9,7 +9,7 @@ use Drupal\Core\Entity\EntityInterface; use Drupal\Core\Entity\EntityTypeInterface; -use Drupal\Core\Language\Language; +use Drupal\Core\Language\LanguageInterface; use Drupal\Core\Render\Element; /** @@ -46,7 +46,7 @@ public function __construct(EntityTypeInterface $entity_type) { * {@inheritdoc} */ public function retranslate(EntityInterface $entity, $langcode = NULL) { - $updated_langcode = !empty($langcode) ? $langcode : $entity->language()->id; + $updated_langcode = !empty($langcode) ? $langcode : $entity->language()->getId(); $translations = $entity->getTranslationLanguages(); foreach ($translations as $langcode => $language) { $entity->translation[$langcode]['outdated'] = $langcode != $updated_langcode; @@ -73,7 +73,7 @@ public function getTranslationAccess(EntityInterface $entity, $op) { * {@inheritdoc} */ public function getSourceLangcode(array $form_state) { - return isset($form_state['content_translation']['source']) ? $form_state['content_translation']['source']->id : FALSE; + return isset($form_state['content_translation']['source']) ? $form_state['content_translation']['source']->getId() : FALSE; } /** @@ -82,7 +82,7 @@ public function getSourceLangcode(array $form_state) { public function entityFormAlter(array &$form, array &$form_state, EntityInterface $entity) { $form_controller = content_translation_form_controller($form_state); $form_langcode = $form_controller->getFormLangcode($form_state); - $entity_langcode = $entity->getUntranslated()->language()->id; + $entity_langcode = $entity->getUntranslated()->language()->getId(); $source_langcode = $this->getSourceLangcode($form_state); $new_translation = !empty($source_langcode); @@ -101,7 +101,7 @@ public function entityFormAlter(array &$form, array &$form_state, EntityInterfac $title = $this->entityFormTitle($entity); // When editing the original values display just the entity label. if ($form_langcode != $entity_langcode) { - $t_args = array('%language' => $languages[$form_langcode]->name, '%title' => $entity->label()); + $t_args = array('%language' => $languages[$form_langcode]->getName(), '%title' => $entity->label()); $title = empty($source_langcode) ? $title . ' [' . t('%language translation', $t_args) . ']' : t('Create %language translation of %title', $t_args); } $form['#title'] = $title; @@ -112,7 +112,7 @@ public function entityFormAlter(array &$form, array &$form_state, EntityInterfac if ($has_translations && $new_translation) { $form['source_langcode'] = array( '#type' => 'details', - '#title' => t('Source language: @language', array('@language' => $languages[$source_langcode]->name)), + '#title' => t('Source language: @language', array('@language' => $languages[$source_langcode]->getName())), '#tree' => TRUE, '#weight' => -100, '#multilingual' => TRUE, @@ -129,9 +129,9 @@ public function entityFormAlter(array &$form, array &$form_state, EntityInterfac '#submit' => array(array($this, 'entityFormSourceChange')), ), ); - foreach (language_list(Language::STATE_CONFIGURABLE) as $language) { - if (isset($translations[$language->id])) { - $form['source_langcode']['source']['#options'][$language->id] = $language->name; + foreach (language_list(LanguageInterface::STATE_CONFIGURABLE) as $language) { + if (isset($translations[$language->getId()])) { + $form['source_langcode']['source']['#options'][$language->getId()] = $language->getName(); } } } @@ -142,9 +142,9 @@ public function entityFormAlter(array &$form, array &$form_state, EntityInterfac $language_widget = isset($form['langcode']) && $form['langcode']['#type'] == 'language_select'; if ($language_widget && $has_translations) { $form['langcode']['#options'] = array(); - foreach (language_list(Language::STATE_CONFIGURABLE) as $language) { - if (empty($translations[$language->id]) || $language->id == $entity_langcode) { - $form['langcode']['#options'][$language->id] = $language->name; + foreach (language_list(LanguageInterface::STATE_CONFIGURABLE) as $language) { + if (empty($translations[$language->getId()]) || $language->getId() == $entity_langcode) { + $form['langcode']['#options'][$language->getId()] = $language->getName(); } } } @@ -434,7 +434,7 @@ public function entityFormSourceChange($form, &$form_state) { $path = $entity->getSystemPath('drupal:content-translation-overview'); $form_state['redirect'] = $path . '/add/' . $source . '/' . $form_controller->getFormLangcode($form_state); $languages = language_list(); - drupal_set_message(t('Source language set to: %language', array('%language' => $languages[$source]->name))); + drupal_set_message(t('Source language set to: %language', array('%language' => $languages[$source]->getName()))); } /** diff --git a/core/modules/content_translation/lib/Drupal/content_translation/FieldTranslationSynchronizer.php b/core/modules/content_translation/lib/Drupal/content_translation/FieldTranslationSynchronizer.php index 196512b..544d1b7 100644 --- a/core/modules/content_translation/lib/Drupal/content_translation/FieldTranslationSynchronizer.php +++ b/core/modules/content_translation/lib/Drupal/content_translation/FieldTranslationSynchronizer.php @@ -50,7 +50,7 @@ public function synchronizeFields(ContentEntityInterface $entity, $sync_langcode // If the entity language is being changed there is nothing to synchronize. $entity_type = $entity->getEntityTypeId(); $entity_unchanged = isset($entity->original) ? $entity->original : $this->entityManager->getStorage($entity_type)->loadUnchanged($entity->id()); - if ($entity->getUntranslated()->language()->id != $entity_unchanged->getUntranslated()->language()->id) { + if ($entity->getUntranslated()->language()->getId() != $entity_unchanged->getUntranslated()->language()->getId()) { return; } diff --git a/core/modules/content_translation/lib/Drupal/content_translation/Form/ContentTranslationDeleteForm.php b/core/modules/content_translation/lib/Drupal/content_translation/Form/ContentTranslationDeleteForm.php index 92a544d..13e0e3f 100644 --- a/core/modules/content_translation/lib/Drupal/content_translation/Form/ContentTranslationDeleteForm.php +++ b/core/modules/content_translation/lib/Drupal/content_translation/Form/ContentTranslationDeleteForm.php @@ -55,7 +55,7 @@ public function getConfirmText() { * {@inheritdoc} */ public function getQuestion() { - return $this->t('Are you sure you want to delete the @language translation of %label?', array('@language' => $this->language->name, '%label' => $this->entity->label())); + return $this->t('Are you sure you want to delete the @language translation of %label?', array('@language' => $this->language->getName(), '%label' => $this->entity->label())); } /** @@ -75,14 +75,14 @@ public function getCancelRoute() { */ public function submitForm(array &$form, array &$form_state) { // Remove the translated values. - $this->entity->removeTranslation($this->language->id); + $this->entity->removeTranslation($this->language->getId()); $this->entity->save(); // Remove any existing path alias for the removed translation. // @todo This should be taken care of by the Path module. if (\Drupal::moduleHandler()->moduleExists('path')) { $path = $this->entity->getSystemPath(); - $conditions = array('source' => $path, 'langcode' => $this->language->id); + $conditions = array('source' => $path, 'langcode' => $this->language->getId()); \Drupal::service('path.alias_storage')->delete($conditions); } diff --git a/core/modules/content_translation/lib/Drupal/content_translation/Tests/ContentTranslationSettingsTest.php b/core/modules/content_translation/lib/Drupal/content_translation/Tests/ContentTranslationSettingsTest.php index 059cb79..664f553 100644 --- a/core/modules/content_translation/lib/Drupal/content_translation/Tests/ContentTranslationSettingsTest.php +++ b/core/modules/content_translation/lib/Drupal/content_translation/Tests/ContentTranslationSettingsTest.php @@ -9,6 +9,7 @@ use Drupal\Core\Language\Language; use Drupal\field\Entity\FieldConfig; +use Drupal\Core\Language\LanguageInterface; use Drupal\simpletest\WebTestBase; /** @@ -76,7 +77,7 @@ function testSettingsUI() { // language is set as default and the language selector is hidden. $edit = array( 'entity_types[comment]' => TRUE, - 'settings[comment][node__comment_article][settings][language][langcode]' => Language::LANGCODE_NOT_SPECIFIED, + 'settings[comment][node__comment_article][settings][language][langcode]' => LanguageInterface::LANGCODE_NOT_SPECIFIED, 'settings[comment][node__comment_article][settings][language][language_show]' => FALSE, 'settings[comment][node__comment_article][translatable]' => TRUE, 'settings[comment][node__comment_article][fields][comment_body]' => TRUE, diff --git a/core/modules/content_translation/lib/Drupal/content_translation/Tests/ContentTranslationSyncImageTest.php b/core/modules/content_translation/lib/Drupal/content_translation/Tests/ContentTranslationSyncImageTest.php index 3f990db..5749baf 100644 --- a/core/modules/content_translation/lib/Drupal/content_translation/Tests/ContentTranslationSyncImageTest.php +++ b/core/modules/content_translation/lib/Drupal/content_translation/Tests/ContentTranslationSyncImageTest.php @@ -8,7 +8,6 @@ namespace Drupal\content_translation\Tests; use Drupal\Core\Entity\EntityInterface; -use Drupal\Core\Language\Language; /** * Tests the Content Translation image field synchronization capability. diff --git a/core/modules/content_translation/lib/Drupal/content_translation/Tests/ContentTranslationSyncUnitTest.php b/core/modules/content_translation/lib/Drupal/content_translation/Tests/ContentTranslationSyncUnitTest.php index a1e0805..509287e 100644 --- a/core/modules/content_translation/lib/Drupal/content_translation/Tests/ContentTranslationSyncUnitTest.php +++ b/core/modules/content_translation/lib/Drupal/content_translation/Tests/ContentTranslationSyncUnitTest.php @@ -7,7 +7,6 @@ namespace Drupal\content_translation\Tests; -use Drupal\Core\Language\Language; use Drupal\simpletest\DrupalUnitTestBase; use Drupal\content_translation\FieldTranslationSynchronizer; diff --git a/core/modules/content_translation/lib/Drupal/content_translation/Tests/ContentTranslationTestBase.php b/core/modules/content_translation/lib/Drupal/content_translation/Tests/ContentTranslationTestBase.php index cec9404..45cf888 100644 --- a/core/modules/content_translation/lib/Drupal/content_translation/Tests/ContentTranslationTestBase.php +++ b/core/modules/content_translation/lib/Drupal/content_translation/Tests/ContentTranslationTestBase.php @@ -103,7 +103,7 @@ protected function setupLanguages() { foreach ($this->langcodes as $langcode) { language_save(new Language(array('id' => $langcode))); } - array_unshift($this->langcodes, \Drupal::languageManager()->getDefaultLanguage()->id); + array_unshift($this->langcodes, \Drupal::languageManager()->getDefaultLanguage()->getId()); } /** diff --git a/core/modules/content_translation/lib/Drupal/content_translation/Tests/ContentTranslationUITest.php b/core/modules/content_translation/lib/Drupal/content_translation/Tests/ContentTranslationUITest.php index 12caf73..10b56cb 100644 --- a/core/modules/content_translation/lib/Drupal/content_translation/Tests/ContentTranslationUITest.php +++ b/core/modules/content_translation/lib/Drupal/content_translation/Tests/ContentTranslationUITest.php @@ -9,7 +9,7 @@ use Drupal\Core\Entity\EntityInterface; use Drupal\Core\Entity\ContentEntityBase; -use Drupal\Core\Language\Language; +use Drupal\Core\Language\LanguageInterface; /** * Tests the Content Translation UI. @@ -251,7 +251,7 @@ protected function getNewEntityValues($langcode) { */ protected function getEditValues($values, $langcode, $new = FALSE) { $edit = $values[$langcode]; - $langcode = $new ? Language::LANGCODE_NOT_SPECIFIED : $langcode; + $langcode = $new ? LanguageInterface::LANGCODE_NOT_SPECIFIED : $langcode; foreach ($values[$langcode] as $property => $value) { if (is_array($value)) { $edit["{$property}[0][value]"] = $value[0]['value']; diff --git a/core/modules/content_translation/lib/Drupal/content_translation/Tests/ContentTranslationWorkflowsTest.php b/core/modules/content_translation/lib/Drupal/content_translation/Tests/ContentTranslationWorkflowsTest.php index 43e5d77..06674b8 100644 --- a/core/modules/content_translation/lib/Drupal/content_translation/Tests/ContentTranslationWorkflowsTest.php +++ b/core/modules/content_translation/lib/Drupal/content_translation/Tests/ContentTranslationWorkflowsTest.php @@ -7,7 +7,7 @@ namespace Drupal\content_translation\Tests; -use Drupal\Core\Language\Language; +use Drupal\Core\Language\LanguageInterface; use Drupal\user\UserInterface; /** @@ -183,7 +183,7 @@ protected function assertWorkflows(UserInterface $user, $expected_status) { * Assert that the current page does not contain shared form elements. */ protected function assertNoSharedElements() { - $language_none = Language::LANGCODE_NOT_SPECIFIED; + $language_none = LanguageInterface::LANGCODE_NOT_SPECIFIED; return $this->assertNoFieldByXPath("//input[@name='field_test_text[$language_none][0][value]']", NULL, 'Shared elements are not available on the translation form.'); } diff --git a/core/modules/dblog/lib/Drupal/dblog/Tests/DbLogTest.php b/core/modules/dblog/lib/Drupal/dblog/Tests/DbLogTest.php index 5b93c34..1807466 100644 --- a/core/modules/dblog/lib/Drupal/dblog/Tests/DbLogTest.php +++ b/core/modules/dblog/lib/Drupal/dblog/Tests/DbLogTest.php @@ -8,7 +8,6 @@ namespace Drupal\dblog\Tests; use Drupal\Component\Utility\Xss; -use Drupal\Core\Language\Language; use Drupal\dblog\Controller\DbLogController; use Drupal\simpletest\WebTestBase; diff --git a/core/modules/editor/lib/Drupal/editor/Tests/QuickEditIntegrationTest.php b/core/modules/editor/lib/Drupal/editor/Tests/QuickEditIntegrationTest.php index 5f0c279..dcaf31d 100644 --- a/core/modules/editor/lib/Drupal/editor/Tests/QuickEditIntegrationTest.php +++ b/core/modules/editor/lib/Drupal/editor/Tests/QuickEditIntegrationTest.php @@ -8,7 +8,7 @@ namespace Drupal\editor\Tests; use Drupal\Component\Serialization\Json; -use Drupal\Core\Language\Language; +use Drupal\Core\Language\LanguageInterface; use Drupal\quickedit\EditorSelector; use Drupal\quickedit\MetadataGenerator; use Drupal\quickedit\Plugin\InPlaceEditorManager; @@ -119,7 +119,7 @@ public function setUp() { */ protected function getSelectedEditor($entity_id, $field_name, $view_mode = 'default') { $entity = entity_load('entity_test', $entity_id, TRUE); - $items = $entity->getTranslation(Language::LANGCODE_NOT_SPECIFIED)->get($field_name); + $items = $entity->getTranslation(LanguageInterface::LANGCODE_NOT_SPECIFIED)->get($field_name); $options = entity_get_display('entity_test', 'entity_test', $view_mode)->getComponent($field_name); return $this->editorSelector->getEditor($options['type'], $items); } @@ -172,7 +172,7 @@ public function testMetadata() { $entity = entity_load('entity_test', $this->entity->id()); // Verify metadata. - $items = $entity->getTranslation(Language::LANGCODE_NOT_SPECIFIED)->get($this->field_name); + $items = $entity->getTranslation(LanguageInterface::LANGCODE_NOT_SPECIFIED)->get($this->field_name); $metadata = $this->metadataGenerator->generateFieldMetadata($items, 'default'); $expected = array( 'access' => TRUE, @@ -212,7 +212,7 @@ public function testGetUntransformedTextCommand() { // Verify AJAX response. $controller = new EditorController(); $request = new Request(); - $response = $controller->getUntransformedText($entity, $this->field_name, Language::LANGCODE_NOT_SPECIFIED, 'default'); + $response = $controller->getUntransformedText($entity, $this->field_name, LanguageInterface::LANGCODE_NOT_SPECIFIED, 'default'); $expected = array( array( 'command' => 'editorGetUntransformedText', diff --git a/core/modules/entity_reference/lib/Drupal/entity_reference/Tests/EntityReferenceAutoCreateTest.php b/core/modules/entity_reference/lib/Drupal/entity_reference/Tests/EntityReferenceAutoCreateTest.php index cc883c8..9c2420b 100644 --- a/core/modules/entity_reference/lib/Drupal/entity_reference/Tests/EntityReferenceAutoCreateTest.php +++ b/core/modules/entity_reference/lib/Drupal/entity_reference/Tests/EntityReferenceAutoCreateTest.php @@ -8,7 +8,6 @@ namespace Drupal\entity_reference\Tests; use Drupal\Core\Field\FieldDefinitionInterface; -use Drupal\Core\Language\Language; use Drupal\simpletest\WebTestBase; /** diff --git a/core/modules/entity_reference/lib/Drupal/entity_reference/Tests/EntityReferenceItemTest.php b/core/modules/entity_reference/lib/Drupal/entity_reference/Tests/EntityReferenceItemTest.php index 8c33d47..90e5a25 100644 --- a/core/modules/entity_reference/lib/Drupal/entity_reference/Tests/EntityReferenceItemTest.php +++ b/core/modules/entity_reference/lib/Drupal/entity_reference/Tests/EntityReferenceItemTest.php @@ -9,7 +9,7 @@ use Drupal\Core\Field\FieldItemListInterface; use Drupal\Core\Field\FieldItemInterface; -use Drupal\Core\Language\Language; +use Drupal\Core\Language\LanguageInterface; use Drupal\field\Tests\FieldUnitTestBase; /** @@ -58,14 +58,14 @@ public function setUp() { $this->vocabulary = entity_create('taxonomy_vocabulary', array( 'name' => $this->randomName(), 'vid' => drupal_strtolower($this->randomName()), - 'langcode' => Language::LANGCODE_NOT_SPECIFIED, + 'langcode' => LanguageInterface::LANGCODE_NOT_SPECIFIED, )); $this->vocabulary->save(); $this->term = entity_create('taxonomy_term', array( 'name' => $this->randomName(), 'vid' => $this->vocabulary->id(), - 'langcode' => Language::LANGCODE_NOT_SPECIFIED, + 'langcode' => LanguageInterface::LANGCODE_NOT_SPECIFIED, )); $this->term->save(); @@ -106,7 +106,7 @@ public function testContentEntityReferenceItem() { $term2 = entity_create('taxonomy_term', array( 'name' => $this->randomName(), 'vid' => $this->term->bundle(), - 'langcode' => Language::LANGCODE_NOT_SPECIFIED, + 'langcode' => LanguageInterface::LANGCODE_NOT_SPECIFIED, )); $term2->save(); @@ -153,7 +153,7 @@ public function testConfigEntityReferenceItem() { $vocabulary2 = entity_create('taxonomy_vocabulary', array( 'name' => $this->randomName(), 'vid' => drupal_strtolower($this->randomName()), - 'langcode' => Language::LANGCODE_NOT_SPECIFIED, + 'langcode' => LanguageInterface::LANGCODE_NOT_SPECIFIED, )); $vocabulary2->save(); diff --git a/core/modules/entity_reference/lib/Drupal/entity_reference/Tests/EntityReferenceSelectionAccessTest.php b/core/modules/entity_reference/lib/Drupal/entity_reference/Tests/EntityReferenceSelectionAccessTest.php index 19f5035..968e60c 100644 --- a/core/modules/entity_reference/lib/Drupal/entity_reference/Tests/EntityReferenceSelectionAccessTest.php +++ b/core/modules/entity_reference/lib/Drupal/entity_reference/Tests/EntityReferenceSelectionAccessTest.php @@ -8,7 +8,7 @@ namespace Drupal\entity_reference\Tests; use Drupal\Core\Field\FieldDefinitionInterface; -use Drupal\Core\Language\Language; +use Drupal\Core\Language\LanguageInterface; use Drupal\comment\CommentInterface; use Drupal\simpletest\WebTestBase; @@ -410,7 +410,7 @@ public function testCommentHandler() { 'pid' => 0, 'status' => CommentInterface::PUBLISHED, 'subject' => 'Comment Published <&>', - 'language' => Language::LANGCODE_NOT_SPECIFIED, + 'language' => LanguageInterface::LANGCODE_NOT_SPECIFIED, ), 'published_unpublished' => array( 'entity_id' => $nodes['published']->id(), @@ -421,7 +421,7 @@ public function testCommentHandler() { 'pid' => 0, 'status' => CommentInterface::NOT_PUBLISHED, 'subject' => 'Comment Unpublished <&>', - 'language' => Language::LANGCODE_NOT_SPECIFIED, + 'language' => LanguageInterface::LANGCODE_NOT_SPECIFIED, ), 'unpublished_published' => array( 'entity_id' => $nodes['unpublished']->id(), @@ -432,7 +432,7 @@ public function testCommentHandler() { 'pid' => 0, 'status' => CommentInterface::NOT_PUBLISHED, 'subject' => 'Comment Published on Unpublished node <&>', - 'language' => Language::LANGCODE_NOT_SPECIFIED, + 'language' => LanguageInterface::LANGCODE_NOT_SPECIFIED, ), ); diff --git a/core/modules/field/lib/Drupal/field/Entity/FieldInstanceConfig.php b/core/modules/field/lib/Drupal/field/Entity/FieldInstanceConfig.php index 6e19dad..bdfcc8f 100644 --- a/core/modules/field/lib/Drupal/field/Entity/FieldInstanceConfig.php +++ b/core/modules/field/lib/Drupal/field/Entity/FieldInstanceConfig.php @@ -598,7 +598,7 @@ public function isMultiple() { public function getDefaultValue(EntityInterface $entity) { if (!empty($this->default_value_function)) { $function = $this->default_value_function; - return $function($entity, $this->getField(), $this, $entity->language()->id); + return $function($entity, $this->getField(), $this, $entity->language()->getId()); } elseif (!empty($this->default_value)) { return $this->default_value; diff --git a/core/modules/field/lib/Drupal/field/Plugin/views/field/Field.php b/core/modules/field/lib/Drupal/field/Plugin/views/field/Field.php index 84b587a..ae333fe 100644 --- a/core/modules/field/lib/Drupal/field/Plugin/views/field/Field.php +++ b/core/modules/field/lib/Drupal/field/Plugin/views/field/Field.php @@ -16,7 +16,7 @@ use Drupal\Core\Entity\ContentEntityDatabaseStorage; use Drupal\Core\Field\FieldDefinitionInterface; use Drupal\Core\Field\FormatterPluginManager; -use Drupal\Core\Language\Language; +use Drupal\Core\Language\LanguageInterface; use Drupal\Core\Language\LanguageManager; use Drupal\Core\Session\AccountInterface; use Drupal\views\Views; @@ -290,12 +290,12 @@ public function query($use_groupby = FALSE) { $field = $field_definition; if ($field->isTranslatable() && !empty($this->view->display_handler->options['field_langcode_add_to_query'])) { $column = $this->tableAlias . '.langcode'; - // By the same reason as field_language the field might be Language::LANGCODE_NOT_SPECIFIED in reality so allow it as well. + // By the same reason as field_language the field might be LanguageInterface::LANGCODE_NOT_SPECIFIED in reality so allow it as well. // @see this::field_langcode() - $default_langcode = language_default()->id; + $default_langcode = language_default()->getId(); $langcode = str_replace( array('***CURRENT_LANGUAGE***', '***DEFAULT_LANGUAGE***'), - array($this->languageManager->getCurrentLanguage(Language::TYPE_CONTENT), $default_langcode), + array($this->languageManager->getCurrentLanguage(LanguageInterface::TYPE_CONTENT), $default_langcode), $this->view->display_handler->options['field_langcode'] ); $placeholder = $this->placeholder(); @@ -900,24 +900,24 @@ protected function addSelfTokens(&$tokens, $item) { */ function field_langcode(EntityInterface $entity) { if ($this->getFieldDefinition()->isTranslatable()) { - $default_langcode = language_default()->id; + $default_langcode = language_default()->getId(); $langcode = str_replace( array('***CURRENT_LANGUAGE***', '***DEFAULT_LANGUAGE***'), - array($this->languageManager->getCurrentLanguage(Language::TYPE_CONTENT), $default_langcode), + array($this->languageManager->getCurrentLanguage(LanguageInterface::TYPE_CONTENT), $default_langcode), $this->view->display_handler->options['field_language'] ); // Give the Entity Field API a chance to fallback to a different language - // (or Language::LANGCODE_NOT_SPECIFIED), in case the field has no data + // (or LanguageInterface::LANGCODE_NOT_SPECIFIED), in case the field has no data // for the selected language. FieldItemListInterface::view() does this as // well, but since the returned language code is used before calling it, // the fallback needs to happen explicitly. - $langcode = $this->entityManager->getTranslationFromContext($entity, $langcode)->language()->id; + $langcode = $this->entityManager->getTranslationFromContext($entity, $langcode)->language()->getId(); return $langcode; } else { - return Language::LANGCODE_NOT_SPECIFIED; + return LanguageInterface::LANGCODE_NOT_SPECIFIED; } } diff --git a/core/modules/field/lib/Drupal/field/Tests/DisplayApiTest.php b/core/modules/field/lib/Drupal/field/Tests/DisplayApiTest.php index 3a31e00..9a9ed1e 100644 --- a/core/modules/field/lib/Drupal/field/Tests/DisplayApiTest.php +++ b/core/modules/field/lib/Drupal/field/Tests/DisplayApiTest.php @@ -7,7 +7,7 @@ namespace Drupal\field\Tests; -use Drupal\Core\Language\Language; +use Drupal\Core\Language\LanguageInterface; /** * Tests the field display API. @@ -149,7 +149,7 @@ function testFieldItemListView() { $setting = $display['settings']['test_formatter_setting_multiple']; $this->assertNoText($this->label, 'Label was not displayed.'); $this->assertText('field_test_entity_display_build_alter', 'Alter fired, display passed.'); - $this->assertText('entity language is ' . Language::LANGCODE_NOT_SPECIFIED, 'Language is placed onto the context.'); + $this->assertText('entity language is ' . LanguageInterface::LANGCODE_NOT_SPECIFIED, 'Language is placed onto the context.'); $array = array(); foreach ($this->values as $delta => $value) { $array[] = $delta . ':' . $value['value']; diff --git a/core/modules/field/lib/Drupal/field/Tests/FieldAttachOtherTest.php b/core/modules/field/lib/Drupal/field/Tests/FieldAttachOtherTest.php index 39f6e28..696021b 100644 --- a/core/modules/field/lib/Drupal/field/Tests/FieldAttachOtherTest.php +++ b/core/modules/field/lib/Drupal/field/Tests/FieldAttachOtherTest.php @@ -7,7 +7,7 @@ namespace Drupal\field\Tests; -use Drupal\Core\Language\Language; +use Drupal\Core\Language\LanguageInterface; /** * Unit test class for non-storage related field_attach_* functions. @@ -180,7 +180,7 @@ function testEntityDisplayViewMultiple() { function testFieldAttachCache() { // Initialize random values and a test entity. $entity_init = entity_create('entity_test', array('type' => $this->instance->bundle)); - $langcode = Language::LANGCODE_NOT_SPECIFIED; + $langcode = LanguageInterface::LANGCODE_NOT_SPECIFIED; $values = $this->_generateTestFieldValues($this->field->getCardinality()); // Non-cacheable entity type. diff --git a/core/modules/field/lib/Drupal/field/Tests/FieldInfoTest.php b/core/modules/field/lib/Drupal/field/Tests/FieldInfoTest.php index c97a481..369645c 100644 --- a/core/modules/field/lib/Drupal/field/Tests/FieldInfoTest.php +++ b/core/modules/field/lib/Drupal/field/Tests/FieldInfoTest.php @@ -7,7 +7,6 @@ namespace Drupal\field\Tests; -use Drupal\Core\Language\Language; /** * Tests field information for fields, instances, and bundles. diff --git a/core/modules/field/lib/Drupal/field/Tests/FieldTestBase.php b/core/modules/field/lib/Drupal/field/Tests/FieldTestBase.php index 3f5d2c5..e105c05 100644 --- a/core/modules/field/lib/Drupal/field/Tests/FieldTestBase.php +++ b/core/modules/field/lib/Drupal/field/Tests/FieldTestBase.php @@ -8,7 +8,7 @@ namespace Drupal\field\Tests; use Drupal\Core\Entity\EntityInterface; -use Drupal\Core\Language\Language; +use Drupal\Core\Language\LanguageInterface; use Drupal\simpletest\WebTestBase; /** @@ -46,11 +46,11 @@ function _generateTestFieldValues($cardinality) { * The array of expected values. * @param $langcode * (Optional) The language code for the values. Defaults to - * Drupal\Core\Language\Language::LANGCODE_NOT_SPECIFIED. + * Drupal\Core\Language\LanguageInterface::LANGCODE_NOT_SPECIFIED. * @param $column * (Optional) The name of the column to check. Defaults to 'value'. */ - function assertFieldValues(EntityInterface $entity, $field_name, $expected_values, $langcode = Language::LANGCODE_NOT_SPECIFIED, $column = 'value') { + function assertFieldValues(EntityInterface $entity, $field_name, $expected_values, $langcode = LanguageInterface::LANGCODE_NOT_SPECIFIED, $column = 'value') { // Re-load the entity to make sure we have the latest changes. entity_get_controller($entity->getEntityTypeId())->resetCache(array($entity->id())); $e = entity_load($entity->getEntityTypeId(), $entity->id()); diff --git a/core/modules/field/lib/Drupal/field/Tests/FieldUnitTestBase.php b/core/modules/field/lib/Drupal/field/Tests/FieldUnitTestBase.php index 5717a23..b94c256 100644 --- a/core/modules/field/lib/Drupal/field/Tests/FieldUnitTestBase.php +++ b/core/modules/field/lib/Drupal/field/Tests/FieldUnitTestBase.php @@ -9,7 +9,7 @@ use Drupal\Component\Utility\Xss; use Drupal\Core\Entity\EntityInterface; -use Drupal\Core\Language\Language; +use Drupal\Core\Language\LanguageInterface; use Drupal\simpletest\DrupalUnitTestBase; /** @@ -145,11 +145,11 @@ function _generateTestFieldValues($cardinality) { * The array of expected values. * @param $langcode * (Optional) The language code for the values. Defaults to - * Drupal\Core\Language\Language::LANGCODE_NOT_SPECIFIED. + * Drupal\Core\Language\LanguageInterface::LANGCODE_NOT_SPECIFIED. * @param $column * (Optional) The name of the column to check. Defaults to 'value'. */ - function assertFieldValues(EntityInterface $entity, $field_name, $expected_values, $langcode = Language::LANGCODE_NOT_SPECIFIED, $column = 'value') { + function assertFieldValues(EntityInterface $entity, $field_name, $expected_values, $langcode = LanguageInterface::LANGCODE_NOT_SPECIFIED, $column = 'value') { // Re-load the entity to make sure we have the latest changes. entity_get_controller($entity->getEntityTypeId())->resetCache(array($entity->id())); $e = entity_load($entity->getEntityTypeId(), $entity->id()); diff --git a/core/modules/field/lib/Drupal/field/Tests/TranslationTest.php b/core/modules/field/lib/Drupal/field/Tests/TranslationTest.php index 89af9c9..2f23729 100644 --- a/core/modules/field/lib/Drupal/field/Tests/TranslationTest.php +++ b/core/modules/field/lib/Drupal/field/Tests/TranslationTest.php @@ -176,7 +176,7 @@ function testTranslatableFieldSaveLoad() { // @todo Test every translation once the Entity Translation API allows for // multilingual defaults. - $langcode = $entity->language()->id; + $langcode = $entity->language()->getId(); $this->assertEqual($entity->getTranslation($langcode)->{$field_name_default}->getValue(), $instance->default_value, format_string('Default value correctly populated for language %language.', array('%language' => $langcode))); // Check that explicit empty values are not overridden with default values. diff --git a/core/modules/field/lib/Drupal/field/Tests/Views/HandlerFieldFieldTest.php b/core/modules/field/lib/Drupal/field/Tests/Views/HandlerFieldFieldTest.php index 9a25836..bb1274e 100644 --- a/core/modules/field/lib/Drupal/field/Tests/Views/HandlerFieldFieldTest.php +++ b/core/modules/field/lib/Drupal/field/Tests/Views/HandlerFieldFieldTest.php @@ -8,7 +8,6 @@ namespace Drupal\field\Tests\Views; use Drupal\Core\Field\FieldDefinitionInterface; -use Drupal\Core\Language\Language; use Drupal\views\ViewExecutable; use Drupal\views\Views; diff --git a/core/modules/field/tests/modules/field_test/field_test.module b/core/modules/field/tests/modules/field_test/field_test.module index 45a0c0d..b0f3a6c 100644 --- a/core/modules/field/tests/modules/field_test/field_test.module +++ b/core/modules/field/tests/modules/field_test/field_test.module @@ -108,7 +108,7 @@ function field_test_entity_display_build_alter(&$output, $context) { } if (isset($output['test_field'])) { - $output['test_field'][] = array('#markup' => 'entity language is ' . $context['entity']->language()->id); + $output['test_field'][] = array('#markup' => 'entity language is ' . $context['entity']->language()->getId()); } } diff --git a/core/modules/field_ui/lib/Drupal/field_ui/Tests/FieldUiTestBase.php b/core/modules/field_ui/lib/Drupal/field_ui/Tests/FieldUiTestBase.php index f103e6d..3e54cea 100644 --- a/core/modules/field_ui/lib/Drupal/field_ui/Tests/FieldUiTestBase.php +++ b/core/modules/field_ui/lib/Drupal/field_ui/Tests/FieldUiTestBase.php @@ -7,7 +7,7 @@ namespace Drupal\field_ui\Tests; -use Drupal\Core\Language\Language; +use Drupal\Core\Language\LanguageInterface; use Drupal\simpletest\WebTestBase; /** @@ -39,7 +39,7 @@ function setUp() { 'name' => $this->randomName(), 'description' => $this->randomName(), 'vid' => drupal_strtolower($this->randomName()), - 'langcode' => Language::LANGCODE_NOT_SPECIFIED, + 'langcode' => LanguageInterface::LANGCODE_NOT_SPECIFIED, 'help' => '', 'nodes' => array('article' => 'article'), 'weight' => mt_rand(0, 10), diff --git a/core/modules/field_ui/lib/Drupal/field_ui/Tests/ManageFieldsTest.php b/core/modules/field_ui/lib/Drupal/field_ui/Tests/ManageFieldsTest.php index 212df05..306c4c4 100644 --- a/core/modules/field_ui/lib/Drupal/field_ui/Tests/ManageFieldsTest.php +++ b/core/modules/field_ui/lib/Drupal/field_ui/Tests/ManageFieldsTest.php @@ -8,7 +8,7 @@ namespace Drupal\field_ui\Tests; use Drupal\Core\Field\FieldDefinitionInterface; -use Drupal\Core\Language\Language; +use Drupal\Core\Language\LanguageInterface; use Drupal\Component\Utility\String; use Drupal\field\Entity\FieldConfig; use Drupal\field\Entity\FieldInstanceConfig; @@ -42,7 +42,7 @@ function setUp() { $vocabulary = entity_create('taxonomy_vocabulary', array( 'name' => 'Tags', 'vid' => 'tags', - 'langcode' => Language::LANGCODE_NOT_SPECIFIED, + 'langcode' => LanguageInterface::LANGCODE_NOT_SPECIFIED, )); $vocabulary->save(); diff --git a/core/modules/file/lib/Drupal/file/Entity/File.php b/core/modules/file/lib/Drupal/file/Entity/File.php index 39f27d6..26416d6 100644 --- a/core/modules/file/lib/Drupal/file/Entity/File.php +++ b/core/modules/file/lib/Drupal/file/Entity/File.php @@ -11,7 +11,7 @@ use Drupal\Core\Entity\EntityStorageInterface; use Drupal\Core\Entity\EntityTypeInterface; use Drupal\Core\Field\FieldDefinition; -use Drupal\Core\Language\Language; +use Drupal\Core\Language\LanguageInterface; use Drupal\file\FileInterface; use Drupal\user\UserInterface; @@ -43,7 +43,7 @@ class File extends ContentEntityBase implements FileInterface { * @var array */ protected $values = array( - 'langcode' => array(Language::LANGCODE_DEFAULT => array(0 => array('value' => Language::LANGCODE_NOT_SPECIFIED))), + 'langcode' => array(LanguageInterface::LANGCODE_DEFAULT => array(0 => array('value' => LanguageInterface::LANGCODE_NOT_SPECIFIED))), ); /** diff --git a/core/modules/file/lib/Drupal/file/Tests/FileFieldPathTest.php b/core/modules/file/lib/Drupal/file/Tests/FileFieldPathTest.php index 3366b2b..b9134d3 100644 --- a/core/modules/file/lib/Drupal/file/Tests/FileFieldPathTest.php +++ b/core/modules/file/lib/Drupal/file/Tests/FileFieldPathTest.php @@ -7,8 +7,6 @@ namespace Drupal\file\Tests; -use Drupal\Core\Language\Language; - /** * Tests that files are uploaded to proper locations. */ diff --git a/core/modules/file/lib/Drupal/file/Tests/FileFieldRSSContentTest.php b/core/modules/file/lib/Drupal/file/Tests/FileFieldRSSContentTest.php index ba46dc6..5b75862 100644 --- a/core/modules/file/lib/Drupal/file/Tests/FileFieldRSSContentTest.php +++ b/core/modules/file/lib/Drupal/file/Tests/FileFieldRSSContentTest.php @@ -7,8 +7,6 @@ namespace Drupal\file\Tests; -use Drupal\Core\Language\Language; - /** * Tests that formatters are working properly. */ diff --git a/core/modules/file/lib/Drupal/file/Tests/FileFieldRevisionTest.php b/core/modules/file/lib/Drupal/file/Tests/FileFieldRevisionTest.php index 070217b..ed06571 100644 --- a/core/modules/file/lib/Drupal/file/Tests/FileFieldRevisionTest.php +++ b/core/modules/file/lib/Drupal/file/Tests/FileFieldRevisionTest.php @@ -7,8 +7,6 @@ namespace Drupal\file\Tests; -use Drupal\Core\Language\Language; - /** * Tests file handling with node revisions. */ diff --git a/core/modules/file/lib/Drupal/file/Tests/FilePrivateTest.php b/core/modules/file/lib/Drupal/file/Tests/FilePrivateTest.php index afb0114..3dce48e 100644 --- a/core/modules/file/lib/Drupal/file/Tests/FilePrivateTest.php +++ b/core/modules/file/lib/Drupal/file/Tests/FilePrivateTest.php @@ -7,8 +7,6 @@ namespace Drupal\file\Tests; -use Drupal\Core\Language\Language; - /** * Tests file access on private nodes. */ diff --git a/core/modules/file/lib/Drupal/file/Tests/FileTokenReplaceTest.php b/core/modules/file/lib/Drupal/file/Tests/FileTokenReplaceTest.php index 35bb593..69ec082 100644 --- a/core/modules/file/lib/Drupal/file/Tests/FileTokenReplaceTest.php +++ b/core/modules/file/lib/Drupal/file/Tests/FileTokenReplaceTest.php @@ -7,8 +7,6 @@ namespace Drupal\file\Tests; -use Drupal\Core\Language\Language; - /** * Tests the file token replacement in strings. */ @@ -53,10 +51,10 @@ function testFileTokenReplacement() { $tests['[file:mime]'] = check_plain($file->getMimeType()); $tests['[file:size]'] = format_size($file->getSize()); $tests['[file:url]'] = check_plain(file_create_url($file->getFileUri())); - $tests['[file:created]'] = format_date($file->getCreatedTime(), 'medium', '', NULL, $language_interface->id); - $tests['[file:created:short]'] = format_date($file->getCreatedTime(), 'short', '', NULL, $language_interface->id); - $tests['[file:changed]'] = format_date($file->getChangedTime(), 'medium', '', NULL, $language_interface->id); - $tests['[file:changed:short]'] = format_date($file->getChangedTime(), 'short', '', NULL, $language_interface->id); + $tests['[file:created]'] = format_date($file->getCreatedTime(), 'medium', '', NULL, $language_interface->getId()); + $tests['[file:created:short]'] = format_date($file->getCreatedTime(), 'short', '', NULL, $language_interface->getId()); + $tests['[file:changed]'] = format_date($file->getChangedTime(), 'medium', '', NULL, $language_interface->getId()); + $tests['[file:changed:short]'] = format_date($file->getChangedTime(), 'short', '', NULL, $language_interface->getId()); $tests['[file:owner]'] = check_plain(user_format_name($this->admin_user)); $tests['[file:owner:uid]'] = $file->getOwnerId(); @@ -64,7 +62,7 @@ function testFileTokenReplacement() { $this->assertFalse(in_array(0, array_map('strlen', $tests)), 'No empty tokens generated.'); foreach ($tests as $input => $expected) { - $output = $token_service->replace($input, array('file' => $file), array('langcode' => $language_interface->id)); + $output = $token_service->replace($input, array('file' => $file), array('langcode' => $language_interface->getId())); $this->assertEqual($output, $expected, format_string('Sanitized file token %token replaced.', array('%token' => $input))); } @@ -75,7 +73,7 @@ function testFileTokenReplacement() { $tests['[file:size]'] = format_size($file->getSize()); foreach ($tests as $input => $expected) { - $output = $token_service->replace($input, array('file' => $file), array('langcode' => $language_interface->id, 'sanitize' => FALSE)); + $output = $token_service->replace($input, array('file' => $file), array('langcode' => $language_interface->getId(), 'sanitize' => FALSE)); $this->assertEqual($output, $expected, format_string('Unsanitized file token %token replaced.', array('%token' => $input))); } } diff --git a/core/modules/file/lib/Drupal/file/Tests/SaveTest.php b/core/modules/file/lib/Drupal/file/Tests/SaveTest.php index 50d6847..daa4048 100644 --- a/core/modules/file/lib/Drupal/file/Tests/SaveTest.php +++ b/core/modules/file/lib/Drupal/file/Tests/SaveTest.php @@ -7,7 +7,7 @@ namespace Drupal\file\Tests; -use Drupal\Core\Language\Language; +use Drupal\Core\Language\LanguageInterface; /** * Tests saving files. @@ -46,7 +46,7 @@ function testFileSave() { $this->assertEqual($loaded_file->isPermanent(), $file->isPermanent(), 'Status was saved correctly.'); $this->assertEqual($file->getSize(), filesize($file->getFileUri()), 'File size was set correctly.', 'File'); $this->assertTrue($file->getChangedTime() > 1, 'File size was set correctly.', 'File'); - $this->assertEqual($loaded_file->langcode->value, Language::LANGCODE_NOT_SPECIFIED, 'Langcode was defaulted correctly.'); + $this->assertEqual($loaded_file->langcode->value, LanguageInterface::LANGCODE_NOT_SPECIFIED, 'Langcode was defaulted correctly.'); // Resave the file, updating the existing record. file_test_reset(); diff --git a/core/modules/filter/filter.module b/core/modules/filter/filter.module index 3efe9ad..6af6efe 100644 --- a/core/modules/filter/filter.module +++ b/core/modules/filter/filter.module @@ -9,7 +9,6 @@ use Drupal\Component\Utility\String; use Drupal\Component\Utility\Xss; use Drupal\Core\Cache\Cache; -use Drupal\Core\Language\Language; use Drupal\Core\Render\Element; use Drupal\Core\Session\AccountInterface; use Drupal\Core\Template\Attribute; @@ -147,13 +146,13 @@ function filter_formats(AccountInterface $account = NULL) { // All available formats are cached for performance. if (!isset($formats['all'])) { $language_interface = \Drupal::languageManager()->getCurrentLanguage(); - if ($cache = \Drupal::cache()->get("filter_formats:{$language_interface->id}")) { + if ($cache = \Drupal::cache()->get("filter_formats:{$language_interface->getId()}")) { $formats['all'] = $cache->data; } else { $formats['all'] = \Drupal::entityManager()->getStorage('filter_format')->loadByProperties(array('status' => TRUE)); uasort($formats['all'], 'Drupal\Core\Config\Entity\ConfigEntityBase::sort'); - \Drupal::cache()->set("filter_formats:{$language_interface->id}", $formats['all'], Cache::PERMANENT, array('filter_formats' => TRUE)); + \Drupal::cache()->set("filter_formats:{$language_interface->getId()}", $formats['all'], Cache::PERMANENT, array('filter_formats' => TRUE)); } } diff --git a/core/modules/filter/lib/Drupal/filter/FilterPluginManager.php b/core/modules/filter/lib/Drupal/filter/FilterPluginManager.php index 2be9e4a..54e1c4e 100644 --- a/core/modules/filter/lib/Drupal/filter/FilterPluginManager.php +++ b/core/modules/filter/lib/Drupal/filter/FilterPluginManager.php @@ -10,7 +10,6 @@ use Drupal\Component\Plugin\PluginManagerBase; use Drupal\Core\Cache\CacheBackendInterface; use Drupal\Core\Extension\ModuleHandlerInterface; -use Drupal\Core\Language\Language; use Drupal\Core\Language\LanguageManager; use Drupal\Core\Plugin\DefaultPluginManager; use Drupal\Core\Plugin\Discovery\AlterDecorator; diff --git a/core/modules/filter/lib/Drupal/filter/Tests/FilterCrudTest.php b/core/modules/filter/lib/Drupal/filter/Tests/FilterCrudTest.php index 041f309..6f153a6 100644 --- a/core/modules/filter/lib/Drupal/filter/Tests/FilterCrudTest.php +++ b/core/modules/filter/lib/Drupal/filter/Tests/FilterCrudTest.php @@ -84,7 +84,7 @@ function testTextFormatCrud() { */ function verifyTextFormat($format) { $t_args = array('%format' => $format->name); - $default_langcode = \Drupal::languageManager()->getDefaultLanguage()->id; + $default_langcode = \Drupal::languageManager()->getDefaultLanguage()->getId(); // Verify the loaded filter has all properties. $filter_format = entity_load('filter_format', $format->format); diff --git a/core/modules/filter/lib/Drupal/filter/Tests/FilterSecurityTest.php b/core/modules/filter/lib/Drupal/filter/Tests/FilterSecurityTest.php index 6321c1b..cb98907 100644 --- a/core/modules/filter/lib/Drupal/filter/Tests/FilterSecurityTest.php +++ b/core/modules/filter/lib/Drupal/filter/Tests/FilterSecurityTest.php @@ -7,7 +7,6 @@ namespace Drupal\filter\Tests; -use Drupal\Core\Language\Language; use Drupal\simpletest\WebTestBase; use Drupal\filter\Plugin\FilterInterface; diff --git a/core/modules/forum/lib/Drupal/forum/Tests/ForumTest.php b/core/modules/forum/lib/Drupal/forum/Tests/ForumTest.php index 6217835..4063d8a 100644 --- a/core/modules/forum/lib/Drupal/forum/Tests/ForumTest.php +++ b/core/modules/forum/lib/Drupal/forum/Tests/ForumTest.php @@ -300,7 +300,7 @@ private function doAdminTests($user) { 'name' => 'Tags', 'description' => $description, 'vid' => 'tags', - 'langcode' => \Drupal::languageManager()->getDefaultLanguage()->id, + 'langcode' => \Drupal::languageManager()->getDefaultLanguage()->getId(), 'help' => $help, )); $vocabulary->save(); diff --git a/core/modules/forum/lib/Drupal/forum/Tests/ForumUninstallTest.php b/core/modules/forum/lib/Drupal/forum/Tests/ForumUninstallTest.php index 130143f..cd695c0 100644 --- a/core/modules/forum/lib/Drupal/forum/Tests/ForumUninstallTest.php +++ b/core/modules/forum/lib/Drupal/forum/Tests/ForumUninstallTest.php @@ -43,7 +43,7 @@ function testForumUninstallWithField() { // Create a taxonomy term. $term = entity_create('taxonomy_term', array( 'name' => t('A term'), - 'langcode' => \Drupal::languageManager()->getDefaultLanguage()->id, + 'langcode' => \Drupal::languageManager()->getDefaultLanguage()->getId(), 'description' => '', 'parent' => array(0), 'vid' => 'forums', diff --git a/core/modules/hal/lib/Drupal/hal/Normalizer/ContentEntityNormalizer.php b/core/modules/hal/lib/Drupal/hal/Normalizer/ContentEntityNormalizer.php index f374fa3..d433656 100644 --- a/core/modules/hal/lib/Drupal/hal/Normalizer/ContentEntityNormalizer.php +++ b/core/modules/hal/lib/Drupal/hal/Normalizer/ContentEntityNormalizer.php @@ -10,7 +10,7 @@ use Drupal\Component\Utility\NestedArray; use Drupal\Core\Entity\EntityManagerInterface; use Drupal\Core\Extension\ModuleHandlerInterface; -use Drupal\Core\Language\Language; +use Drupal\Core\Language\LanguageInterface; use Drupal\rest\LinkManager\LinkManagerInterface; use Symfony\Component\Serializer\Exception\UnexpectedValueException; @@ -136,7 +136,7 @@ public function denormalize($data, $class, $format = NULL, array $context = arra $langcode = language_get_default_langcode($typed_data_ids['entity_type'], $typed_data_ids['bundle']); } else { - $langcode = Language::LANGCODE_NOT_SPECIFIED; + $langcode = LanguageInterface::LANGCODE_NOT_SPECIFIED; } $entity_type = $this->entityManager->getDefinition($typed_data_ids['entity_type']); diff --git a/core/modules/hal/lib/Drupal/hal/Normalizer/FieldNormalizer.php b/core/modules/hal/lib/Drupal/hal/Normalizer/FieldNormalizer.php index 99a669c..d898815 100644 --- a/core/modules/hal/lib/Drupal/hal/Normalizer/FieldNormalizer.php +++ b/core/modules/hal/lib/Drupal/hal/Normalizer/FieldNormalizer.php @@ -26,9 +26,11 @@ class FieldNormalizer extends NormalizerBase { * Implements \Symfony\Component\Serializer\Normalizer\NormalizerInterface::normalize() */ public function normalize($field, $format = NULL, array $context = array()) { + /** @var \Drupal\Core\Field\FieldItemInterface $field */ $normalized_field_items = array(); // Get the field definition. + /** @var \Drupal\Core\Entity\ContentEntityInterface $entity */ $entity = $field->getEntity(); $field_name = $field->getName(); $field_definition = $field->getFieldDefinition(); @@ -43,8 +45,8 @@ public function normalize($field, $format = NULL, array $context = array()) { // to the field item values. else { foreach ($entity->getTranslationLanguages() as $language) { - $context['langcode'] = $language->id; - $translation = $entity->getTranslation($language->id); + $context['langcode'] = $language->getId(); + $translation = $entity->getTranslation($language->getId()); $translated_field = $translation->get($field_name); $normalized_field_items = array_merge($normalized_field_items, $this->normalizeFieldItems($translated_field, $format, $context)); } diff --git a/core/modules/language/language.module b/core/modules/language/language.module index f35da4d..efbf47d 100644 --- a/core/modules/language/language.module +++ b/core/modules/language/language.module @@ -6,7 +6,7 @@ */ use Drupal\Core\PhpStorage\PhpStorageFactory; -use Drupal\Core\Language\Language; +use Drupal\Core\Language\LanguageInterface; use Drupal\language\ConfigurableLanguageManager; use Drupal\language\ConfigurableLanguageManagerInterface; use Drupal\language\Entity\Language as LanguageEntity; @@ -148,7 +148,7 @@ function language_element_info_alter(&$type) { $type['language_select']['#process'] = array_merge($type['language_select']['#process'], array('language_process_language_select', 'form_process_select', 'ajax_process_form')); $type['language_select']['#theme'] = 'select'; $type['language_select']['#theme_wrappers'] = array_merge($type['language_select']['#theme_wrappers'], array('form_element')); - $type['language_select']['#languages'] = Language::STATE_CONFIGURABLE; + $type['language_select']['#languages'] = LanguageInterface::STATE_CONFIGURABLE; $type['language_select']['#multiple'] = FALSE; } } @@ -168,7 +168,7 @@ function language_process_language_select($element) { if (!isset($element['#options'])) { $element['#options'] = array(); foreach (\Drupal::languageManager()->getLanguages($element['#languages']) as $langcode => $language) { - $element['#options'][$langcode] = $language->locked ? t('- @name -', array('@name' => $language->name)) : $language->name; + $element['#options'][$langcode] = $language->isLocked() ? t('- @name -', array('@name' => $language->getName())) : $language->getName(); } } // Add "Built-in English" language to the select when the default value is @@ -209,14 +209,14 @@ function language_element_info() { */ function language_configuration_element_default_options() { $language_options = array( - 'site_default' => t("Site's default language (!language)", array('!language' => \Drupal::languageManager()->getDefaultLanguage()->name)), + 'site_default' => t("Site's default language (!language)", array('!language' => \Drupal::languageManager()->getDefaultLanguage()->getName())), 'current_interface' => t('Current interface language'), 'authors_default' => t("Author's preferred language"), ); - $languages = \Drupal::languageManager()->getLanguages(Language::STATE_ALL); + $languages = \Drupal::languageManager()->getLanguages(LanguageInterface::STATE_ALL); foreach ($languages as $langcode => $language) { - $language_options[$langcode] = $language->locked ? t('- @name -', array('@name' => $language->name)) : $language->name; + $language_options[$langcode] = $language->isLocked() ? t('- @name -', array('@name' => $language->getName())) : $language->getName(); } return $language_options; @@ -389,11 +389,11 @@ function language_get_default_langcode($entity_type, $bundle) { $language_interface = \Drupal::languageManager()->getCurrentLanguage(); switch ($configuration['langcode']) { case 'site_default': - $default_value = \Drupal::languageManager()->getDefaultLanguage()->id; + $default_value = \Drupal::languageManager()->getDefaultLanguage()->getId(); break; case 'current_interface': - $default_value = $language_interface->id; + $default_value = $language_interface->getId(); break; case 'authors_default': @@ -403,7 +403,7 @@ function language_get_default_langcode($entity_type, $bundle) { $default_value = $language_code; } else { - $default_value = $language_interface->id; + $default_value = $language_interface->getId(); } break; } @@ -419,28 +419,28 @@ function language_get_default_langcode($entity_type, $bundle) { /** * API function to add or update a language. * - * @param $language + * @param \Drupal\Core\Language\LanguageInterface $language * Language object with properties corresponding to the 'language' * configuration properties. */ -function language_save($language) { - $language_entity = entity_load('language_entity', $language->id); +function language_save(LanguageInterface $language) { + $language_entity = entity_load('language_entity', $language->getId()); if (!$language_entity) { $language_entity = entity_create('language_entity', array( - 'id' => $language->id, + 'id' => $language->getId(), )); } $language->is_new = $language_entity->isNew(); // Assign language properties to language entity. - $language_entity->label = isset($language->name) ? $language->name : ''; - $language_entity->direction = isset($language->direction) ? $language->direction : '0'; - $language_entity->locked = !empty($language->locked); - $language_entity->weight = isset($language->weight) ? $language->weight : 0; - $language_entity->setDefault(!empty($language->default)); + $language_entity->label = $language->getName(); + $language_entity->direction = $language->getDirection(); + $language_entity->locked = $language->isLocked(); + $language_entity->weight = $language->getWeight(); + $language_entity->setDefault($language->isDefault()); $language_entity->save(); - $t_args = array('%language' => $language->name, '%langcode' => $language->id); - if ($language->is_new) { + $t_args = array('%language' => $language->getName(), '%langcode' => $language->getId()); + if ($language_entity->isNew()) { watchdog('language', 'The %language (%langcode) language has been created.', $t_args); } else { @@ -460,12 +460,12 @@ function language_save($language) { * TRUE if language is successfully deleted. Otherwise FALSE. */ function language_delete($langcode) { - $languages = \Drupal::languageManager()->getLanguages(Language::STATE_ALL); - if (isset($languages[$langcode]) && !$languages[$langcode]->locked) { + $languages = \Drupal::languageManager()->getLanguages(LanguageInterface::STATE_ALL); + if (isset($languages[$langcode]) && !$languages[$langcode]->isLocked()) { $language = $languages[$langcode]; // Remove the language. - entity_delete_multiple('language_entity', array($language->id)); + entity_delete_multiple('language_entity', array($language->getId())); $language_manager = \Drupal::languageManager(); $language_manager->reset(); @@ -479,7 +479,7 @@ function language_delete($langcode) { ConfigurableLanguageManager::rebuildServices(); } - $t_args = array('%language' => $language->name, '%langcode' => $language->id); + $t_args = array('%language' => $language->getName(), '%langcode' => $language->getId()); watchdog('language', 'The %language (%langcode) language has been removed.', $t_args); return TRUE; } @@ -502,18 +502,18 @@ function language_delete($langcode) { */ function language_language_types_info() { return array( - Language::TYPE_INTERFACE => array( + LanguageInterface::TYPE_INTERFACE => array( 'name' => t('User interface text'), 'description' => t('Order of language detection methods for user interface text. If a translation of user interface text is available in the detected language, it will be displayed.'), 'locked' => TRUE, ), - Language::TYPE_CONTENT => array( + LanguageInterface::TYPE_CONTENT => array( 'name' => t('Content'), 'description' => t('Order of language detection methods for content. If a version of content is available in the detected language, it will be displayed.'), 'fixed' => array(LanguageNegotiationUI::METHOD_ID), 'locked' => TRUE, ), - Language::TYPE_URL => array( + LanguageInterface::TYPE_URL => array( 'fixed' => array(LanguageNegotiationUrl::METHOD_ID, LanguageNegotiationUrlFallback::METHOD_ID), 'locked' => TRUE, ), @@ -535,10 +535,10 @@ function language_negotiation_url_prefixes_update() { foreach (\Drupal::languageManager()->getLanguages() as $language) { // The prefix for this language should be updated if it's not assigned yet // or the prefix is set to the empty string. - if (empty($prefixes[$language->id])) { + if (empty($prefixes[$language->getId()])) { // For the default language, set the prefix to the empty string, // otherwise use the langcode. - $prefixes[$language->id] = !empty($language->default) ? '' : $language->id; + $prefixes[$language->getId()] = $language->isDefault() ? '' : $language->getId(); } // Otherwise we keep the configured prefix. } @@ -663,12 +663,12 @@ function language_form_system_regional_settings_alter(&$form, &$form_state) { $languages = \Drupal::languageManager()->getLanguages(); $default = \Drupal::languageManager()->getDefaultLanguage(); foreach ($languages as $key => $language) { - $language_options[$key] = $language->name; + $language_options[$key] = $language->getName(); } $form['locale']['site_default_language'] = array( '#type' => 'select', '#title' => t('Default language'), - '#default_value' => $default->id, + '#default_value' => $default->getId(), '#options' => $language_options, '#description' => t('It is not recommended to change the default language on a working site. Configure the Selected language setting on the detection and selection page to change the fallback language for language selection.', array('@language-detection' => url('admin/config/regional/language/detection'))), '#weight' => -1, @@ -685,6 +685,6 @@ function language_form_system_regional_settings_alter(&$form, &$form_state) { function language_system_regional_settings_form_submit($form, &$form_state) { $languages = \Drupal::languageManager()->getLanguages(); $language = $languages[$form_state['values']['site_default_language']]; - $language->default = TRUE; + $language->setDefault(TRUE); language_save($language); } diff --git a/core/modules/language/lib/Drupal/language/Config/LanguageConfigFactoryOverride.php b/core/modules/language/lib/Drupal/language/Config/LanguageConfigFactoryOverride.php index bfadec0..983283b 100644 --- a/core/modules/language/lib/Drupal/language/Config/LanguageConfigFactoryOverride.php +++ b/core/modules/language/lib/Drupal/language/Config/LanguageConfigFactoryOverride.php @@ -10,7 +10,7 @@ use Drupal\Core\Config\Config; use Drupal\Core\Config\StorageInterface; use Drupal\Core\Config\TypedConfigManagerInterface; -use Drupal\Core\Language\Language; +use Drupal\Core\Language\LanguageInterface; use Drupal\Core\Language\LanguageDefault; use Symfony\Component\EventDispatcher\EventDispatcherInterface; @@ -73,7 +73,7 @@ public function loadOverrides($names) { $data = $this->storage->readMultiple(array_values($language_names)); // Re-key the data array to use configuration names rather than override // names. - $prefix_length = strlen(static::LANGUAGE_CONFIG_PREFIX . '.' . $this->language->id) + 1; + $prefix_length = strlen(static::LANGUAGE_CONFIG_PREFIX . '.' . $this->language->getId()) + 1; foreach ($data as $key => $value) { unset($data[$key]); $key = substr($key, $prefix_length); @@ -109,7 +109,7 @@ protected function getLanguageConfigNames(array $names) { $language_names = array(); if (isset($this->language)) { foreach ($names as $name) { - if ($language_name = $this->getLanguageConfigName($this->language->id, $name)) { + if ($language_name = $this->getLanguageConfigName($this->language->getId(), $name)) { $language_names[$name] = $language_name; } } @@ -139,7 +139,7 @@ protected function getLanguageConfigName($langcode, $name) { * {@inheritdoc} */ public function getCacheSuffix() { - return $this->language ? $this->language->id : NULL; + return $this->language ? $this->language->getId() : NULL; } /** @@ -152,7 +152,7 @@ public function getLanguage() { /** * {@inheritdoc} */ - public function setLanguage(Language $language = NULL) { + public function setLanguage(LanguageInterface $language = NULL) { $this->language = $language; return $this; } diff --git a/core/modules/language/lib/Drupal/language/Config/LanguageConfigFactoryOverrideInterface.php b/core/modules/language/lib/Drupal/language/Config/LanguageConfigFactoryOverrideInterface.php index 1c3de55..81b2e39 100644 --- a/core/modules/language/lib/Drupal/language/Config/LanguageConfigFactoryOverrideInterface.php +++ b/core/modules/language/lib/Drupal/language/Config/LanguageConfigFactoryOverrideInterface.php @@ -8,7 +8,7 @@ namespace Drupal\language\Config; use Drupal\Core\Config\ConfigFactoryOverrideInterface; -use Drupal\Core\Language\Language; +use Drupal\Core\Language\LanguageInterface; use Drupal\Core\Language\LanguageDefault; /** @@ -32,12 +32,12 @@ public function getLanguage(); /** * Sets the language to be used in configuration overrides. * - * @param \Drupal\Core\Language\Language $language + * @param \Drupal\Core\Language\LanguageInterface $language * The language object used to override configuration data. * * @return $this */ - public function setLanguage(Language $language = NULL); + public function setLanguage(LanguageInterface $language = NULL); /** * Sets the language to be used in configuration overrides from the default. diff --git a/core/modules/language/lib/Drupal/language/ConfigurableLanguageManager.php b/core/modules/language/lib/Drupal/language/ConfigurableLanguageManager.php index 101449c..e34c126 100644 --- a/core/modules/language/lib/Drupal/language/ConfigurableLanguageManager.php +++ b/core/modules/language/lib/Drupal/language/ConfigurableLanguageManager.php @@ -7,6 +7,7 @@ namespace Drupal\language; +use Drupal\Core\Language\LanguageInterface as CoreLanguageInterface; use Drupal\Core\PhpStorage\PhpStorageFactory; use Drupal\Core\Config\ConfigFactoryInterface; use Drupal\Core\Extension\ModuleHandlerInterface; @@ -135,7 +136,7 @@ public function init() { * {@inheritdoc} */ public function isMultilingual() { - return count($this->getLanguages(Language::STATE_CONFIGURABLE)) > 1; + return count($this->getLanguages(CoreLanguageInterface::STATE_CONFIGURABLE)) > 1; } /** @@ -197,7 +198,7 @@ public function saveLanguageTypesConfiguration(array $values) { /** * {@inheritdoc} */ - public function getCurrentLanguage($type = Language::TYPE_INTERFACE) { + public function getCurrentLanguage($type = CoreLanguageInterface::TYPE_INTERFACE) { if (!isset($this->negotiatedLanguages[$type])) { // Ensure we have a valid value for this language type. $this->negotiatedLanguages[$type] = $this->getDefaultLanguage(); @@ -214,8 +215,8 @@ public function getCurrentLanguage($type = Language::TYPE_INTERFACE) { // original strings which can be translated by calling them again // afterwards. This can happen for instance while parsing negotiation // method definitions. - elseif ($type == Language::TYPE_INTERFACE) { - return new Language(array('id' => Language::LANGCODE_SYSTEM)); + elseif ($type == CoreLanguageInterface::TYPE_INTERFACE) { + return new Language(array('id' => CoreLanguageInterface::LANGCODE_SYSTEM)); } } } @@ -269,12 +270,12 @@ public function setNegotiator(LanguageNegotiatorInterface $negotiator) { /** * {@inheritdoc} */ - public function getLanguages($flags = Language::STATE_CONFIGURABLE) { + public function getLanguages($flags = CoreLanguageInterface::STATE_CONFIGURABLE) { if (!isset($this->languages)) { // Prepopulate the language list with the default language to keep things // working even if we have no configuration. $default = $this->getDefaultLanguage(); - $this->languages = array($default->id => $default); + $this->languages = array($default->getId() => $default); // Retrieve the config storage to list available languages. $prefix = 'language.entity.'; @@ -287,17 +288,17 @@ public function getLanguages($flags = Language::STATE_CONFIGURABLE) { $langcode = $data['id']; // Initialize default property so callers have an easy reference and can // save the same object without data loss. - $data['default'] = ($langcode == $default->id); + $data['default'] = ($langcode == $default->getId()); $data['name'] = $data['label']; $this->languages[$langcode] = new Language($data); - $weight = max(array($weight, $this->languages[$langcode]->weight)); + $weight = max(array($weight, $this->languages[$langcode]->getWeight())); } // Add locked languages, they will be filtered later if needed. $this->languages += $this->getDefaultLockedLanguages($weight); // Sort the language list by weight then title. - Language::sort($this->languages); + uasort($this->languages, '\Drupal\Core\Language\Language::sort'); } return parent::getLanguages($flags); @@ -310,15 +311,15 @@ public function updateLockedLanguageWeights() { $max_weight = 0; // Get maximum weight to update the system languages to keep them on bottom. - foreach ($this->getLanguages(Language::STATE_CONFIGURABLE) as $language) { - if (!$language->locked && $language->weight > $max_weight) { - $max_weight = $language->weight; + foreach ($this->getLanguages(CoreLanguageInterface::STATE_CONFIGURABLE) as $language) { + if (!$language->isLocked() && $language->getWeight() > $max_weight) { + $max_weight = $language->getWeight(); } } // Loop locked languages to maintain the existing order. - $locked_languages = $this->getLanguages(Language::STATE_LOCKED); - $config_ids = array_map(function($language) { return 'language.entity.' . $language->id; }, $locked_languages); + $locked_languages = $this->getLanguages(CoreLanguageInterface::STATE_LOCKED); + $config_ids = array_map(function(CoreLanguageInterface $language) { return 'language.entity.' . $language->getId(); }, $locked_languages); foreach ($this->configFactory->loadMultiple($config_ids) as $config_id => $config) { // Update system languages weight. $max_weight++; @@ -332,10 +333,10 @@ public function updateLockedLanguageWeights() { */ public function getFallbackCandidates($langcode = NULL, array $context = array()) { if ($this->isMultilingual()) { - // Get languages ordered by weight, add Language::LANGCODE_NOT_SPECIFIED + // Get languages ordered by weight, add LanguageInterface::LANGCODE_NOT_SPECIFIED // at the end. $candidates = array_keys($this->getLanguages()); - $candidates[] = Language::LANGCODE_NOT_SPECIFIED; + $candidates[] = CoreLanguageInterface::LANGCODE_NOT_SPECIFIED; $candidates = array_combine($candidates, $candidates); // The first candidate should always be the desired language if specified. @@ -388,7 +389,7 @@ public function getLanguageSwitchLinks($type, $path) { /** * {@inheritdoc} */ - public function setConfigOverrideLanguage(Language $language = NULL) { + public function setConfigOverrideLanguage(CoreLanguageInterface $language = NULL) { $this->configFactoryOverride->setLanguage($language); return $this; } diff --git a/core/modules/language/lib/Drupal/language/ConfigurableLanguageManagerInterface.php b/core/modules/language/lib/Drupal/language/ConfigurableLanguageManagerInterface.php index 9bbf2ce..8c34c1b 100644 --- a/core/modules/language/lib/Drupal/language/ConfigurableLanguageManagerInterface.php +++ b/core/modules/language/lib/Drupal/language/ConfigurableLanguageManagerInterface.php @@ -7,7 +7,6 @@ namespace Drupal\language; -use Drupal\Core\Language\Language; use Drupal\Core\Language\LanguageManagerInterface; use Symfony\Component\HttpFoundation\Request; diff --git a/core/modules/language/lib/Drupal/language/Entity/Language.php b/core/modules/language/lib/Drupal/language/Entity/Language.php index 8a2f9fe..d77d576 100644 --- a/core/modules/language/lib/Drupal/language/Entity/Language.php +++ b/core/modules/language/lib/Drupal/language/Entity/Language.php @@ -87,9 +87,9 @@ class Language extends ConfigEntityBase implements LanguageInterface { * container using the language.default service in when the entity is saved. * The value is set correctly when a language entity is created or loaded. * - * @see \Drupal\language\Entity\Language::postSave() - * @see \Drupal\language\Entity\Language::isDefault() - * @see \Drupal\language\Entity\Language::setDefault() + * @see \Drupal\language\Entity\LanguageInterface::postSave() + * @see \Drupal\language\Entity\LanguageInterface::isDefault() + * @see \Drupal\language\Entity\LanguageInterface::setDefault() * * @var bool */ @@ -101,8 +101,8 @@ class Language extends ConfigEntityBase implements LanguageInterface { * This property is not saved to the language entity, but is needed for * detecting when to rebuild the services. * - * @see \Drupal\language\Entity\Language::preSave() - * @see \Drupal\language\Entity\Language::postSave() + * @see \Drupal\language\Entity\LanguageInterface::preSave() + * @see \Drupal\language\Entity\LanguageInterface::postSave() * * @var bool */ @@ -137,7 +137,7 @@ public function preSave(EntityStorageInterface $storage) { parent::preSave($storage); // Store whether or not the site is already multilingual so that we can // rebuild services if necessary during - // \Drupal\language\Entity\Language::postSave(). + // \Drupal\language\Entity\LanguageInterface::postSave(). $this->preSaveMultilingual = \Drupal::languageManager()->isMultilingual(); // Languages are picked from a predefined list which is given in English. // For the uncommon case of custom languages the label should be given in diff --git a/core/modules/language/lib/Drupal/language/EventSubscriber/LanguageRequestSubscriber.php b/core/modules/language/lib/Drupal/language/EventSubscriber/LanguageRequestSubscriber.php index 7700611..fcbd232 100644 --- a/core/modules/language/lib/Drupal/language/EventSubscriber/LanguageRequestSubscriber.php +++ b/core/modules/language/lib/Drupal/language/EventSubscriber/LanguageRequestSubscriber.php @@ -86,7 +86,7 @@ public function onKernelRequestLanguage(GetResponseEvent $event) { } // After the language manager has initialized, set the default langcode // for the string translations. - $langcode = $this->languageManager->getCurrentLanguage()->id; + $langcode = $this->languageManager->getCurrentLanguage()->getId(); $this->translation->setDefaultLangcode($langcode); } } diff --git a/core/modules/language/lib/Drupal/language/Form/LanguageAddForm.php b/core/modules/language/lib/Drupal/language/Form/LanguageAddForm.php index 3eb0bc6..1f74246 100644 --- a/core/modules/language/lib/Drupal/language/Form/LanguageAddForm.php +++ b/core/modules/language/lib/Drupal/language/Form/LanguageAddForm.php @@ -98,7 +98,7 @@ public function submitForm(array &$form, array &$form_state) { // Save the language and inform the user that it happened. $language = language_save($language); - drupal_set_message($this->t('The language %language has been created and can now be used.', array('%language' => $language->name))); + drupal_set_message($this->t('The language %language has been created and can now be used.', array('%language' => $language->getName()))); // Tell the user they have the option to add a language switcher block // to their theme so they can switch between the languages. @@ -124,7 +124,7 @@ public function validateCustom(array $form, array &$form_state) { $this->validateCommon($form['custom_language'], $form_state); if ($language = language_load($langcode)) { - $this->setFormError('langcode', $form_state, $this->t('The language %language (%langcode) already exists.', array('%language' => $language->name, '%langcode' => $langcode))); + $this->setFormError('langcode', $form_state, $this->t('The language %language (%langcode) already exists.', array('%language' => $language->getName(), '%langcode' => $langcode))); } } else { @@ -142,7 +142,7 @@ public function validatePredefined($form, &$form_state) { } else { if ($language = language_load($langcode)) { - $this->setFormError('predefined_langcode', $form_state, $this->t('The language %language (%langcode) already exists.', array('%language' => $language->name, '%langcode' => $langcode))); + $this->setFormError('predefined_langcode', $form_state, $this->t('The language %language (%langcode) already exists.', array('%language' => $language->getName(), '%langcode' => $langcode))); } } } diff --git a/core/modules/language/lib/Drupal/language/Form/LanguageDeleteForm.php b/core/modules/language/lib/Drupal/language/Form/LanguageDeleteForm.php index 241bbe7..6edb8aa 100644 --- a/core/modules/language/lib/Drupal/language/Form/LanguageDeleteForm.php +++ b/core/modules/language/lib/Drupal/language/Form/LanguageDeleteForm.php @@ -89,7 +89,7 @@ public function buildForm(array $form, array &$form_state) { $langcode = $this->entity->id(); // Warn and redirect user when attempting to delete the default language. - if (language_default()->id == $langcode) { + if (language_default()->getId() == $langcode) { drupal_set_message($this->t('The default language cannot be deleted.')); $url = $this->urlGenerator->generateFromPath('admin/config/regional/language', array('absolute' => TRUE)); return new RedirectResponse($url); diff --git a/core/modules/language/lib/Drupal/language/Form/LanguageEditForm.php b/core/modules/language/lib/Drupal/language/Form/LanguageEditForm.php index 2dacdc2..9c69bb8 100644 --- a/core/modules/language/lib/Drupal/language/Form/LanguageEditForm.php +++ b/core/modules/language/lib/Drupal/language/Form/LanguageEditForm.php @@ -51,8 +51,8 @@ public function submitForm(array &$form, array &$form_state) { $languages = language_list(); $langcode = $form_state['values']['langcode']; $language = $languages[$langcode]; - $language->name = $form_state['values']['name']; - $language->direction = $form_state['values']['direction']; + $language->setName($form_state['values']['name']); + $language->setDirection($form_state['values']['direction']); language_save($language); $form_state['redirect_route']['route_name'] = 'language.admin_overview'; diff --git a/core/modules/language/lib/Drupal/language/Form/LanguageFormBase.php b/core/modules/language/lib/Drupal/language/Form/LanguageFormBase.php index d3719bc..583787a 100644 --- a/core/modules/language/lib/Drupal/language/Form/LanguageFormBase.php +++ b/core/modules/language/lib/Drupal/language/Form/LanguageFormBase.php @@ -9,7 +9,7 @@ use Drupal\Component\Utility\String; use Drupal\Core\Entity\EntityForm; -use Drupal\Core\Language\Language; +use Drupal\Core\Language\LanguageInterface; use Drupal\language\ConfigurableLanguageManagerInterface; use Symfony\Component\DependencyInjection\ContainerInterface; @@ -85,8 +85,8 @@ public function commonForm(array &$form) { '#description' => $this->t('Direction that text in this language is presented.'), '#default_value' => $language->direction, '#options' => array( - Language::DIRECTION_LTR => $this->t('Left to right'), - Language::DIRECTION_RTL => $this->t('Right to left'), + LanguageInterface::DIRECTION_LTR => $this->t('Left to right'), + LanguageInterface::DIRECTION_RTL => $this->t('Right to left'), ), ); diff --git a/core/modules/language/lib/Drupal/language/Form/NegotiationBrowserForm.php b/core/modules/language/lib/Drupal/language/Form/NegotiationBrowserForm.php index f82e54a..3dc4ad7 100644 --- a/core/modules/language/lib/Drupal/language/Form/NegotiationBrowserForm.php +++ b/core/modules/language/lib/Drupal/language/Form/NegotiationBrowserForm.php @@ -63,7 +63,7 @@ public function buildForm(array $form, array &$form_state) { $existing_languages = array(); foreach ($languages as $langcode => $language) { - $existing_languages[$langcode] = $language->name; + $existing_languages[$langcode] = $language->getName(); } // If we have no languages available, present the list of predefined languages diff --git a/core/modules/language/lib/Drupal/language/Form/NegotiationSelectedForm.php b/core/modules/language/lib/Drupal/language/Form/NegotiationSelectedForm.php index 14c13f4..47d61eb 100644 --- a/core/modules/language/lib/Drupal/language/Form/NegotiationSelectedForm.php +++ b/core/modules/language/lib/Drupal/language/Form/NegotiationSelectedForm.php @@ -7,7 +7,7 @@ namespace Drupal\language\Form; -use Drupal\Core\Language\Language; +use Drupal\Core\Language\LanguageInterface; use Drupal\Core\Form\ConfigFormBase; /** @@ -30,7 +30,7 @@ public function buildForm(array $form, array &$form_state) { $form['selected_langcode'] = array( '#type' => 'language_select', '#title' => t('Language'), - '#languages' => Language::STATE_CONFIGURABLE | Language::STATE_SITE_DEFAULT, + '#languages' => LanguageInterface::STATE_CONFIGURABLE | LanguageInterface::STATE_SITE_DEFAULT, '#default_value' => $config->get('selected_langcode'), ); diff --git a/core/modules/language/lib/Drupal/language/Form/NegotiationUrlForm.php b/core/modules/language/lib/Drupal/language/Form/NegotiationUrlForm.php index d8c2490..bfec4ac 100644 --- a/core/modules/language/lib/Drupal/language/Form/NegotiationUrlForm.php +++ b/core/modules/language/lib/Drupal/language/Form/NegotiationUrlForm.php @@ -72,17 +72,17 @@ public function buildForm(array $form, array &$form_state) { $prefixes = language_negotiation_url_prefixes(); $domains = language_negotiation_url_domains(); foreach ($languages as $langcode => $language) { - $t_args = array('%language' => $language->name, '%langcode' => $language->id); + $t_args = array('%language' => $language->getName(), '%langcode' => $language->getId()); $form['prefix'][$langcode] = array( '#type' => 'textfield', - '#title' => $language->default ? t('%language (%langcode) path prefix (Default language)', $t_args) : t('%language (%langcode) path prefix', $t_args), + '#title' => $language->isDefault() ? t('%language (%langcode) path prefix (Default language)', $t_args) : t('%language (%langcode) path prefix', $t_args), '#maxlength' => 64, '#default_value' => isset($prefixes[$langcode]) ? $prefixes[$langcode] : '', '#field_prefix' => $base_url . '/', ); $form['domain'][$langcode] = array( '#type' => 'textfield', - '#title' => t('%language (%langcode) domain', array('%language' => $language->name, '%langcode' => $language->id)), + '#title' => t('%language (%langcode) domain', array('%language' => $language->getName(), '%langcode' => $language->getId())), '#maxlength' => 128, '#default_value' => isset($domains[$langcode]) ? $domains[$langcode] : '', ); @@ -105,7 +105,7 @@ public function validateForm(array &$form, array &$form_state) { $value = $form_state['values']['prefix'][$langcode]; if ($value === '') { - if (!$language->default && $form_state['values']['language_negotiation_url_part'] == LanguageNegotiationUrl::CONFIG_PATH_PREFIX) { + if (!$language->isDefault() && $form_state['values']['language_negotiation_url_part'] == LanguageNegotiationUrl::CONFIG_PATH_PREFIX) { // Throw a form error if the prefix is blank for a non-default language, // although it is required for selected negotiation type. $this->setFormError("prefix][$langcode", $form_state, t('The prefix may only be left blank for the default language.')); @@ -119,7 +119,7 @@ public function validateForm(array &$form, array &$form_state) { elseif (isset($count[$value]) && $count[$value] > 1) { // Throw a form error if there are two languages with the same // domain/prefix. - $this->setFormError("prefix][$langcode", $form_state, t('The prefix for %language, %value, is not unique.', array('%language' => $language->name, '%value' => $value))); + $this->setFormError("prefix][$langcode", $form_state, t('The prefix for %language, %value, is not unique.', array('%language' => $language->getName(), '%value' => $value))); } } @@ -129,7 +129,7 @@ public function validateForm(array &$form, array &$form_state) { $value = $form_state['values']['domain'][$langcode]; if ($value === '') { - if (!$language->default && $form_state['values']['language_negotiation_url_part'] == LanguageNegotiationUrl::CONFIG_DOMAIN) { + if (!$language->isDefault() && $form_state['values']['language_negotiation_url_part'] == LanguageNegotiationUrl::CONFIG_DOMAIN) { // Throw a form error if the domain is blank for a non-default language, // although it is required for selected negotiation type. $this->setFormError("domain][$langcode", $form_state, t('The domain may only be left blank for the default language.')); @@ -138,7 +138,7 @@ public function validateForm(array &$form, array &$form_state) { elseif (isset($count[$value]) && $count[$value] > 1) { // Throw a form error if there are two languages with the same // domain/domain. - $this->setFormError("domain][$langcode", $form_state, t('The domain for %language, %value, is not unique.', array('%language' => $language->name, '%value' => $value))); + $this->setFormError("domain][$langcode", $form_state, t('The domain for %language, %value, is not unique.', array('%language' => $language->getName(), '%value' => $value))); } } diff --git a/core/modules/language/lib/Drupal/language/LanguageAccessController.php b/core/modules/language/lib/Drupal/language/LanguageAccessController.php index 2cc17d0..5ebded0 100644 --- a/core/modules/language/lib/Drupal/language/LanguageAccessController.php +++ b/core/modules/language/lib/Drupal/language/LanguageAccessController.php @@ -9,7 +9,6 @@ use Drupal\Core\Entity\EntityAccessController; use Drupal\Core\Entity\EntityInterface; -use Drupal\Core\Language\Language; use Drupal\Core\Session\AccountInterface; class LanguageAccessController extends EntityAccessController { diff --git a/core/modules/language/lib/Drupal/language/LanguageListBuilder.php b/core/modules/language/lib/Drupal/language/LanguageListBuilder.php index c5bd66a..36209c5 100644 --- a/core/modules/language/lib/Drupal/language/LanguageListBuilder.php +++ b/core/modules/language/lib/Drupal/language/LanguageListBuilder.php @@ -49,7 +49,7 @@ public function getDefaultOperations(EntityInterface $entity) { $default = language_default(); // Deleting the site default language is not allowed. - if ($entity->id() == $default->id) { + if ($entity->id() == $default->getId()) { unset($operations['delete']); } diff --git a/core/modules/language/lib/Drupal/language/LanguageNegotiationMethodBase.php b/core/modules/language/lib/Drupal/language/LanguageNegotiationMethodBase.php index 9ed0f7c..a10924b 100644 --- a/core/modules/language/lib/Drupal/language/LanguageNegotiationMethodBase.php +++ b/core/modules/language/lib/Drupal/language/LanguageNegotiationMethodBase.php @@ -8,7 +8,7 @@ namespace Drupal\language; use Drupal\Core\Config\ConfigFactoryInterface; -use Drupal\Core\Language\Language; +use Drupal\Core\Language\LanguageInterface as CoreLanguageInterface; use Drupal\Core\Session\AccountInterface; /** @@ -61,9 +61,9 @@ public function setCurrentUser(AccountInterface $current_user) { /** * {@inheritdoc} */ - public function persist(Language $language) { + public function persist(CoreLanguageInterface $language) { // Remember the method ID used to detect the language. - $language->method_id = static::METHOD_ID; + $language->setNegotiationMethodId(static::METHOD_ID); } } diff --git a/core/modules/language/lib/Drupal/language/LanguageNegotiationMethodInterface.php b/core/modules/language/lib/Drupal/language/LanguageNegotiationMethodInterface.php index fefa585..bffe23a 100644 --- a/core/modules/language/lib/Drupal/language/LanguageNegotiationMethodInterface.php +++ b/core/modules/language/lib/Drupal/language/LanguageNegotiationMethodInterface.php @@ -8,7 +8,7 @@ namespace Drupal\language; use Drupal\Core\Config\ConfigFactoryInterface; -use Drupal\Core\Language\Language; +use Drupal\Core\Language\LanguageInterface as CoreLanguageInterface; use Drupal\Core\Session\AccountInterface; use Symfony\Component\HttpFoundation\Request; @@ -57,9 +57,9 @@ public function getLangcode(Request $request = NULL); /** * Notifies the plugin that the language code it returned has been accepted. * - * @param \Drupal\Core\Language\Language $language + * @param \Drupal\Core\Language\LanguageInterface $language * The accepted language. */ - public function persist(Language $language); + public function persist(CoreLanguageInterface $language); } diff --git a/core/modules/language/lib/Drupal/language/LanguageNegotiator.php b/core/modules/language/lib/Drupal/language/LanguageNegotiator.php index ec924e3..d567c54 100644 --- a/core/modules/language/lib/Drupal/language/LanguageNegotiator.php +++ b/core/modules/language/lib/Drupal/language/LanguageNegotiator.php @@ -159,7 +159,7 @@ public function initializeType($type) { if (!$language) { // If no other language was found use the default one. $language = $this->languageManager->getDefaultLanguage(); - $language->method_id = LanguageNegotiatorInterface::METHOD_ID; + $language->setNegotiationMethodId(LanguageNegotiatorInterface::METHOD_ID); } return $language; diff --git a/core/modules/language/lib/Drupal/language/LanguageNegotiatorInterface.php b/core/modules/language/lib/Drupal/language/LanguageNegotiatorInterface.php index d12fd6f..73bef59 100644 --- a/core/modules/language/lib/Drupal/language/LanguageNegotiatorInterface.php +++ b/core/modules/language/lib/Drupal/language/LanguageNegotiatorInterface.php @@ -41,7 +41,7 @@ * configurable: * @code * function mymodule_language_types_info_alter(&$language_types) { - * unset($language_types[Language::TYPE_CONTENT]['fixed']); + * unset($language_types[LanguageInterface::TYPE_CONTENT]['fixed']); * } * @endcode * @@ -91,7 +91,7 @@ * // If we are on an administrative path, override with the default * language. * if ($request->query->has('q') && strtok($request->query->get('q'), '/') == 'admin') { - * return $this->languageManager->getDefaultLanguage()->id; + * return $this->languageManager->getDefaultLanguage()->getId(); * } * return $langcode; * } diff --git a/core/modules/language/lib/Drupal/language/LanguageServiceProvider.php b/core/modules/language/lib/Drupal/language/LanguageServiceProvider.php index 95eb700..4f81af8 100644 --- a/core/modules/language/lib/Drupal/language/LanguageServiceProvider.php +++ b/core/modules/language/lib/Drupal/language/LanguageServiceProvider.php @@ -10,7 +10,7 @@ use Drupal\Core\Config\BootstrapConfigStorageFactory; use Drupal\Core\DependencyInjection\ContainerBuilder; use Drupal\Core\DependencyInjection\ServiceProviderBase; -use Drupal\Core\Language\Language; +use Drupal\Core\Language\LanguageInterface as CoreLanguageInterface; use Symfony\Component\DependencyInjection\Reference; /** @@ -81,7 +81,7 @@ protected function isMultilingual() { // container has finished building. $config_storage = BootstrapConfigStorageFactory::get(); $config_ids = array_filter($config_storage->listAll($prefix), function($config_id) use ($prefix) { - return $config_id != $prefix . Language::LANGCODE_NOT_SPECIFIED && $config_id != $prefix . Language::LANGCODE_NOT_APPLICABLE; + return $config_id != $prefix . CoreLanguageInterface::LANGCODE_NOT_SPECIFIED && $config_id != $prefix . CoreLanguageInterface::LANGCODE_NOT_APPLICABLE; }); return count($config_ids) > 1; } diff --git a/core/modules/language/lib/Drupal/language/Plugin/Condition/Language.php b/core/modules/language/lib/Drupal/language/Plugin/Condition/Language.php index 9dda571..cc20f42 100644 --- a/core/modules/language/lib/Drupal/language/Plugin/Condition/Language.php +++ b/core/modules/language/lib/Drupal/language/Plugin/Condition/Language.php @@ -72,8 +72,8 @@ public function summary() { $language_names = array_reduce($language_list, function(&$result, $item) use ($selected) { // If the current item of the $language_list array is one of the selected // languages, add it to the $results array. - if (!empty($selected[$item->id])) { - $result[$item->id] = $item->name; + if (!empty($selected[$item->getId()])) { + $result[$item->getId()] = $item->getName(); } return $result; }, array()); @@ -99,7 +99,7 @@ public function evaluate() { $language = $this->getContextValue('language'); // Language visibility settings. if (!empty($this->configuration['langcodes'])) { - return !empty($this->configuration['langcodes'][$language->id]); + return !empty($this->configuration['langcodes'][$language->getId()]); } return TRUE; } diff --git a/core/modules/language/lib/Drupal/language/Plugin/LanguageNegotiation/LanguageNegotiationSession.php b/core/modules/language/lib/Drupal/language/Plugin/LanguageNegotiation/LanguageNegotiationSession.php index e56278d..d20a187 100644 --- a/core/modules/language/lib/Drupal/language/Plugin/LanguageNegotiation/LanguageNegotiationSession.php +++ b/core/modules/language/lib/Drupal/language/Plugin/LanguageNegotiation/LanguageNegotiationSession.php @@ -7,7 +7,7 @@ namespace Drupal\language\Plugin\LanguageNegotiation; -use Drupal\Core\Language\Language; +use Drupal\Core\Language\LanguageInterface; use Drupal\Core\PathProcessor\OutboundPathProcessorInterface; use Drupal\language\LanguageNegotiationMethodBase; use Drupal\language\LanguageSwitcherInterface; @@ -68,12 +68,12 @@ public function getLangcode(Request $request = NULL) { /** * {@inheritdoc} */ - public function persist(Language $language) { + public function persist(LanguageInterface $language) { parent::persist($language); // We need to update the session parameter with the request value only if we // have an authenticated user. - $langcode = $language->id; + $langcode = $language->getId(); if ($langcode && $this->languageManager) { $languages = $this->languageManager->getLanguages(); if ($this->currentUser->isAuthenticated() && isset($languages[$langcode])) { @@ -127,15 +127,15 @@ function getLanguageSwitchLinks(Request $request, $type, $path) { $links = array(); $config = $this->config->get('language.negotiation')->get('session'); $param = $config['parameter']; - $language_query = isset($_SESSION[$param]) ? $_SESSION[$param] : $this->languageManager->getCurrentLanguage($type)->id; + $language_query = isset($_SESSION[$param]) ? $_SESSION[$param] : $this->languageManager->getCurrentLanguage($type)->getId(); $query = array(); parse_str($request->getQueryString(), $query); foreach ($this->languageManager->getLanguages() as $language) { - $langcode = $language->id; + $langcode = $language->getId(); $links[$langcode] = array( 'href' => $path, - 'title' => $language->name, + 'title' => $language->getName(), 'attributes' => array('class' => array('language-link')), 'query' => $query, ); diff --git a/core/modules/language/lib/Drupal/language/Plugin/LanguageNegotiation/LanguageNegotiationUI.php b/core/modules/language/lib/Drupal/language/Plugin/LanguageNegotiation/LanguageNegotiationUI.php index 3b64974..fd7eb75 100644 --- a/core/modules/language/lib/Drupal/language/Plugin/LanguageNegotiation/LanguageNegotiationUI.php +++ b/core/modules/language/lib/Drupal/language/Plugin/LanguageNegotiation/LanguageNegotiationUI.php @@ -15,7 +15,7 @@ * * @Plugin( * id = Drupal\language\Plugin\LanguageNegotiation\LanguageNegotiationUI::METHOD_ID, - * types = {Drupal\Core\Language\Language::TYPE_CONTENT}, + * types = {Drupal\Core\Language\LanguageInterface::TYPE_CONTENT}, * weight = 9, * name = @Translation("Interface"), * description = @Translation("Use the detected interface language.") @@ -32,7 +32,7 @@ class LanguageNegotiationUI extends LanguageNegotiationMethodBase { * {@inheritdoc} */ public function getLangcode(Request $request = NULL) { - return $this->languageManager ? $this->languageManager->getCurrentLanguage()->id : NULL; + return $this->languageManager ? $this->languageManager->getCurrentLanguage()->getId() : NULL; } } diff --git a/core/modules/language/lib/Drupal/language/Plugin/LanguageNegotiation/LanguageNegotiationUrl.php b/core/modules/language/lib/Drupal/language/Plugin/LanguageNegotiation/LanguageNegotiationUrl.php index 42a0933..d869d4f 100644 --- a/core/modules/language/lib/Drupal/language/Plugin/LanguageNegotiation/LanguageNegotiationUrl.php +++ b/core/modules/language/lib/Drupal/language/Plugin/LanguageNegotiation/LanguageNegotiationUrl.php @@ -7,7 +7,7 @@ namespace Drupal\language\Plugin\LanguageNegotiation; -use Drupal\Core\Language\Language; +use Drupal\Core\Language\LanguageInterface; use Drupal\Core\PathProcessor\InboundPathProcessorInterface; use Drupal\Core\PathProcessor\OutboundPathProcessorInterface; use Drupal\language\LanguageNegotiationMethodBase; @@ -19,7 +19,7 @@ * * @Plugin( * id = \Drupal\language\Plugin\LanguageNegotiation\LanguageNegotiationUrl::METHOD_ID, - * types = {\Drupal\Core\Language\Language::TYPE_INTERFACE, \Drupal\Core\Language\Language::TYPE_CONTENT, \Drupal\Core\Language\Language::TYPE_URL}, + * types = {\Drupal\Core\Language\LanguageInterface::TYPE_INTERFACE, \Drupal\Core\Language\LanguageInterface::TYPE_CONTENT, \Drupal\Core\Language\LanguageInterface::TYPE_URL}, * weight = -8, * name = @Translation("URL"), * description = @Translation("Language from the URL (Path prefix or domain)."), @@ -62,14 +62,14 @@ public function getLangcode(Request $request = NULL) { // Search prefix within added languages. $negotiated_language = FALSE; foreach ($languages as $language) { - if (isset($config['prefixes'][$language->id]) && $config['prefixes'][$language->id] == $prefix) { + if (isset($config['prefixes'][$language->getId()]) && $config['prefixes'][$language->getId()] == $prefix) { $negotiated_language = $language; break; } } if ($negotiated_language) { - $langcode = $negotiated_language->id; + $langcode = $negotiated_language->getId(); } break; @@ -78,13 +78,13 @@ public function getLangcode(Request $request = NULL) { $http_host = $request->getHost(); foreach ($languages as $language) { // Skip the check if the language doesn't have a domain. - if (!empty($config['domains'][$language->id])) { + if (!empty($config['domains'][$language->getId()])) { // Ensure that there is exactly one protocol in the URL when // checking the hostname. - $host = 'http://' . str_replace(array('http://', 'https://'), '', $config['domains'][$language->id]); + $host = 'http://' . str_replace(array('http://', 'https://'), '', $config['domains'][$language->getId()]); $host = parse_url($host, PHP_URL_HOST); if ($http_host == $host) { - $langcode = $language->id; + $langcode = $language->getId(); break; } } @@ -106,7 +106,7 @@ public function processInbound($path, Request $request) { // Search prefix within added languages. foreach ($this->languageManager->getLanguages() as $language) { - if (isset($config['prefixes'][$language->id]) && $config['prefixes'][$language->id] == $prefix) { + if (isset($config['prefixes'][$language->getId()]) && $config['prefixes'][$language->getId()] == $prefix) { // Rebuild $path with the language removed. $path = implode('/', $parts); break; @@ -129,21 +129,21 @@ public function processOutbound($path, &$options = array(), Request $request = N $languages = array_flip(array_keys($this->languageManager->getLanguages())); // Language can be passed as an option, or we go for current URL language. if (!isset($options['language'])) { - $language_url = $this->languageManager->getCurrentLanguage(Language::TYPE_URL); + $language_url = $this->languageManager->getCurrentLanguage(LanguageInterface::TYPE_URL); $options['language'] = $language_url; } // We allow only added languages here. - elseif (!is_object($options['language']) || !isset($languages[$options['language']->id])) { + elseif (!is_object($options['language']) || !isset($languages[$options['language']->getId()])) { return $path; } $config = $this->config->get('language.negotiation')->get('url'); if ($config['source'] == LanguageNegotiationUrl::CONFIG_PATH_PREFIX) { - if (is_object($options['language']) && !empty($config['prefixes'][$options['language']->id])) { - return empty($path) ? $config['prefixes'][$options['language']->id] : $config['prefixes'][$options['language']->id] . '/' . $path; + if (is_object($options['language']) && !empty($config['prefixes'][$options['language']->getId()])) { + return empty($path) ? $config['prefixes'][$options['language']->getId()] : $config['prefixes'][$options['language']->getId()] . '/' . $path; } } elseif ($config['source'] == LanguageNegotiationUrl::CONFIG_DOMAIN) { - if (is_object($options['language']) && !empty($config['domains'][$options['language']->id])) { + if (is_object($options['language']) && !empty($config['domains'][$options['language']->getId()])) { // Save the original base URL. If it contains a port, we need to // retain it below. @@ -154,7 +154,7 @@ public function processOutbound($path, &$options = array(), Request $request = N // Ask for an absolute URL with our modified base URL. $options['absolute'] = TRUE; - $options['base_url'] = $url_scheme . '://' . $config['domains'][$options['language']->id]; + $options['base_url'] = $url_scheme . '://' . $config['domains'][$options['language']->getId()]; // In case either the original base URL or the HTTP host contains a // port, retain it. @@ -189,9 +189,9 @@ function getLanguageSwitchLinks(Request $request, $type, $path) { $links = array(); foreach ($this->languageManager->getLanguages() as $language) { - $links[$language->id] = array( + $links[$language->getId()] = array( 'href' => $path, - 'title' => $language->name, + 'title' => $language->getName(), 'language' => $language, 'attributes' => array('class' => array('language-link')), ); diff --git a/core/modules/language/lib/Drupal/language/Plugin/LanguageNegotiation/LanguageNegotiationUrlFallback.php b/core/modules/language/lib/Drupal/language/Plugin/LanguageNegotiation/LanguageNegotiationUrlFallback.php index 2310153..abaa6e3 100644 --- a/core/modules/language/lib/Drupal/language/Plugin/LanguageNegotiation/LanguageNegotiationUrlFallback.php +++ b/core/modules/language/lib/Drupal/language/Plugin/LanguageNegotiation/LanguageNegotiationUrlFallback.php @@ -34,7 +34,7 @@ * * @Plugin( * id = Drupal\language\Plugin\LanguageNegotiation\LanguageNegotiationUrlFallback::METHOD_ID, - * types = {Drupal\Core\Language\Language::TYPE_URL}, + * types = {Drupal\Core\Language\LanguageInterface::TYPE_URL}, * weight = 8, * name = @Translation("URL fallback"), * description = @Translation("Use an already detected language for URLs if none is found.") @@ -62,11 +62,11 @@ public function getLangcode(Request $request = NULL) { // information, a missing URL language information indicates that URL // language should be the default one, otherwise we fall back to an // already detected language. - if (($prefix && empty($config['prefixes'][$default->id])) || (!$prefix && empty($config['domains'][$default->id]))) { - $langcode = $default->id; + if (($prefix && empty($config['prefixes'][$default->getId()])) || (!$prefix && empty($config['domains'][$default->getId()]))) { + $langcode = $default->getId(); } else { - $langcode = $this->languageManager->getCurrentLanguage()->id; + $langcode = $this->languageManager->getCurrentLanguage()->getId(); } } diff --git a/core/modules/language/lib/Drupal/language/Plugin/views/field/LanguageField.php b/core/modules/language/lib/Drupal/language/Plugin/views/field/LanguageField.php index 3909fcd..152104d 100644 --- a/core/modules/language/lib/Drupal/language/Plugin/views/field/LanguageField.php +++ b/core/modules/language/lib/Drupal/language/Plugin/views/field/LanguageField.php @@ -44,7 +44,7 @@ public function render(ResultRow $values) { // ready, see http://drupal.org/node/1616594. $value = $this->getValue($values); $language = language_load($value); - return $language ? $language->name : ''; + return $language ? $language->getName() : ''; } } diff --git a/core/modules/language/lib/Drupal/language/Tests/LanguageConfigurationElementTest.php b/core/modules/language/lib/Drupal/language/Tests/LanguageConfigurationElementTest.php index c7c85f1..f9721a7 100644 --- a/core/modules/language/lib/Drupal/language/Tests/LanguageConfigurationElementTest.php +++ b/core/modules/language/lib/Drupal/language/Tests/LanguageConfigurationElementTest.php @@ -84,17 +84,17 @@ public function testDefaultLangcode() { language_save_default_configuration('custom_type', 'custom_bundle', array('langcode' => 'current_interface', 'language_show' => TRUE)); $langcode = language_get_default_langcode('custom_type', 'custom_bundle'); $language_interface = \Drupal::languageManager()->getCurrentLanguage(); - $this->assertEqual($langcode, $language_interface->id); + $this->assertEqual($langcode, $language_interface->getId()); // Site's default. $old_default = \Drupal::languageManager()->getDefaultLanguage(); // Ensure the language entity default value is correct. $language_entity = entity_load('language_entity', $old_default->getId()); $this->assertTrue($language_entity->get('default'), 'The en language entity is flagged as the default language.'); - $old_default->default = FALSE; + $old_default->setDefault(FALSE); language_save($old_default); $new_default = \Drupal::languageManager()->getLanguage('cc'); - $new_default->default = TRUE; + $new_default->setDefault(TRUE); language_save($new_default); language_save_default_configuration('custom_type', 'custom_bundle', array('langcode' => 'site_default', 'language_show' => TRUE)); $langcode = language_get_default_langcode('custom_type', 'custom_bundle'); @@ -104,7 +104,7 @@ public function testDefaultLangcode() { $language_entity = entity_load('language_entity', $old_default->getId()); $this->assertFalse($language_entity->get('default'), 'The en language entity is not flagged as the default language.'); $language_entity = entity_load('language_entity', 'cc'); - // Check calling the Drupal\language\Entity\Language::isDefault() method + // Check calling the Drupal\language\Entity\LanguageInterface::isDefault() method // directly. $this->assertTrue($language_entity->isDefault(), 'The cc language entity is flagged as the default language.'); diff --git a/core/modules/language/lib/Drupal/language/Tests/LanguageConfigurationTest.php b/core/modules/language/lib/Drupal/language/Tests/LanguageConfigurationTest.php index 6093263..03edfaf 100644 --- a/core/modules/language/lib/Drupal/language/Tests/LanguageConfigurationTest.php +++ b/core/modules/language/lib/Drupal/language/Tests/LanguageConfigurationTest.php @@ -7,7 +7,7 @@ namespace Drupal\language\Tests; -use Drupal\Core\Language\Language; +use Drupal\Core\Language\LanguageInterface; use Drupal\simpletest\WebTestBase; /** @@ -160,9 +160,9 @@ protected function checkConfigurableLanguageWeight($state = 'by default') { \Drupal::languageManager()->reset(); $max_configurable_language_weight = $this->getHighestConfigurableLanguageWeight(); $replacements = array('@event' => $state); - foreach (\Drupal::languageManager()->getLanguages(Language::STATE_LOCKED) as $locked_language) { - $replacements['%language'] = $locked_language->name; - $this->assertTrue($locked_language->weight > $max_configurable_language_weight, format_string('System language %language has higher weight than configurable languages @event', $replacements)); + foreach (\Drupal::languageManager()->getLanguages(LanguageInterface::STATE_LOCKED) as $locked_language) { + $replacements['%language'] = $locked_language->getName(); + $this->assertTrue($locked_language->getWeight() > $max_configurable_language_weight, format_string('System language %language has higher weight than configurable languages @event', $replacements)); } } diff --git a/core/modules/language/lib/Drupal/language/Tests/LanguageCustomLanguageConfigurationTest.php b/core/modules/language/lib/Drupal/language/Tests/LanguageCustomLanguageConfigurationTest.php index 9554dd8..5a34b85 100644 --- a/core/modules/language/lib/Drupal/language/Tests/LanguageCustomLanguageConfigurationTest.php +++ b/core/modules/language/lib/Drupal/language/Tests/LanguageCustomLanguageConfigurationTest.php @@ -7,6 +7,7 @@ namespace Drupal\language\Tests; +use Drupal\Core\Language\LanguageInterface; use Drupal\simpletest\WebTestBase; use Drupal\Core\Language\Language; @@ -49,7 +50,7 @@ public function testLanguageConfiguration() { $this->assertText(t('!name field is required.', array('!name' => t('Language code')))); $this->assertText(t('!name field is required.', array('!name' => t('Language name in English')))); $empty_language = new Language(); - $this->assertFieldChecked('edit-direction-' . $empty_language->direction, 'Consistent usage of language direction.'); + $this->assertFieldChecked('edit-direction-' . $empty_language->getDirection(), 'Consistent usage of language direction.'); $this->assertEqual($this->getUrl(), url('admin/config/regional/language/add', array('absolute' => TRUE)), 'Correct page redirection.'); // Test validation of invalid values. @@ -57,7 +58,7 @@ public function testLanguageConfiguration() { 'predefined_langcode' => 'custom', 'langcode' => 'white space', 'name' => 'evil markup', - 'direction' => Language::DIRECTION_LTR, + 'direction' => LanguageInterface::DIRECTION_LTR, ); $this->drupalPostForm('admin/config/regional/language/add', $edit, t('Add custom language')); $this->assertRaw(t('%field may only contain characters a-z, underscores, or hyphens.', array('%field' => t('Language code')))); @@ -69,7 +70,7 @@ public function testLanguageConfiguration() { 'predefined_langcode' => 'custom', 'langcode' => 'de', 'name' => 'German', - 'direction' => Language::DIRECTION_LTR, + 'direction' => LanguageInterface::DIRECTION_LTR, ); // Add the language the first time. diff --git a/core/modules/language/lib/Drupal/language/Tests/LanguageDependencyInjectionTest.php b/core/modules/language/lib/Drupal/language/Tests/LanguageDependencyInjectionTest.php index 067c477..7701e13 100644 --- a/core/modules/language/lib/Drupal/language/Tests/LanguageDependencyInjectionTest.php +++ b/core/modules/language/lib/Drupal/language/Tests/LanguageDependencyInjectionTest.php @@ -62,7 +62,7 @@ function testDependencyInjectedNewDefaultLanguage() { // The language system creates a Language object which contains the // same properties as the new default language object. $result = \Drupal::languageManager()->getCurrentLanguage(); - $this->assertIdentical($result->id, 'fr'); + $this->assertIdentical($result->getId(), 'fr'); // Delete the language to check that we fallback to the default. try { @@ -77,7 +77,7 @@ function testDependencyInjectedNewDefaultLanguage() { language_save($default_language); language_delete('fr'); $result = \Drupal::languageManager()->getCurrentLanguage(); - $this->assertIdentical($result->id, $default_language->id); + $this->assertIdentical($result->getId(), $default_language->getId()); } } diff --git a/core/modules/language/lib/Drupal/language/Tests/LanguageFallbackTest.php b/core/modules/language/lib/Drupal/language/Tests/LanguageFallbackTest.php index fb621d8..b35fce9 100644 --- a/core/modules/language/lib/Drupal/language/Tests/LanguageFallbackTest.php +++ b/core/modules/language/lib/Drupal/language/Tests/LanguageFallbackTest.php @@ -8,6 +8,7 @@ namespace Drupal\language\Tests; use Drupal\Core\Language\Language; +use Drupal\Core\Language\LanguageInterface; /** * Tests the language fallback behavior. @@ -30,8 +31,8 @@ protected function setUp() { for ($i = 0; $i < 3; $i++) { $language = new Language(); - $language->id = $this->randomName(2); - $language->weight = -$i; + $language->setId($this->randomName(2)); + $language->setWeight(-$i); language_save($language); } } @@ -41,7 +42,7 @@ protected function setUp() { */ public function testCandidates() { $language_list = $this->languageManager->getLanguages(); - $expected = array_keys($language_list + array(Language::LANGCODE_NOT_SPECIFIED => NULL)); + $expected = array_keys($language_list + array(LanguageInterface::LANGCODE_NOT_SPECIFIED => NULL)); // Check that language fallback candidates by default are all the available // languages sorted by weight. @@ -57,20 +58,20 @@ public function testCandidates() { // Check that candidates are alterable for specific operations. $this->state->set('language_test.fallback_alter.candidates', FALSE); $this->state->set('language_test.fallback_operation_alter.candidates', TRUE); - $expected[] = Language::LANGCODE_NOT_SPECIFIED; - $expected[] = Language::LANGCODE_NOT_APPLICABLE; + $expected[] = LanguageInterface::LANGCODE_NOT_SPECIFIED; + $expected[] = LanguageInterface::LANGCODE_NOT_APPLICABLE; $candidates = $this->languageManager->getFallbackCandidates(NULL, array('operation' => 'test')); $this->assertEqual(array_values($candidates), $expected, 'Language fallback candidates are alterable for specific operations.'); // Check that when the site is monolingual no language fallback is applied. - $default_langcode = $this->languageManager->getDefaultLanguage()->id; + $default_langcode = $this->languageManager->getDefaultLanguage()->getId(); foreach ($language_list as $langcode => $language) { if ($langcode != $default_langcode) { language_delete($langcode); } } $candidates = $this->languageManager->getFallbackCandidates(); - $this->assertEqual(array_values($candidates), array(Language::LANGCODE_DEFAULT), 'Language fallback is not applied when the Language module is not enabled.'); + $this->assertEqual(array_values($candidates), array(LanguageInterface::LANGCODE_DEFAULT), 'Language fallback is not applied when the Language module is not enabled.'); } } diff --git a/core/modules/language/lib/Drupal/language/Tests/LanguageListTest.php b/core/modules/language/lib/Drupal/language/Tests/LanguageListTest.php index d5abded..2482bf9 100644 --- a/core/modules/language/lib/Drupal/language/Tests/LanguageListTest.php +++ b/core/modules/language/lib/Drupal/language/Tests/LanguageListTest.php @@ -7,6 +7,7 @@ namespace Drupal\language\Tests; +use Drupal\Core\Language\LanguageInterface; use Drupal\simpletest\WebTestBase; use Drupal\Core\Language\Language; @@ -179,10 +180,10 @@ function testLanguageStates() { $expected_all_languages = array('l4' => 'l4', 'l3' => 'l3', 'l2' => 'l2', 'l1' => 'l1', 'en' => 'en', 'und' => 'und', 'zxx' => 'zxx'); $expected_conf_languages = array('l3' => 'l3', 'l1' => 'l1', 'en' => 'en'); - $locked_languages = $this->container->get('language_manager')->getLanguages(Language::STATE_LOCKED); + $locked_languages = $this->container->get('language_manager')->getLanguages(LanguageInterface::STATE_LOCKED); $this->assertEqual(array_diff_key($expected_locked_languages, $locked_languages), array(), 'Locked languages loaded correctly.'); - $all_languages = $this->container->get('language_manager')->getLanguages(Language::STATE_ALL); + $all_languages = $this->container->get('language_manager')->getLanguages(LanguageInterface::STATE_ALL); $this->assertEqual(array_diff_key($expected_all_languages, $all_languages), array(), 'All languages loaded correctly.'); $conf_languages = $this->container->get('language_manager')->getLanguages(); diff --git a/core/modules/language/lib/Drupal/language/Tests/LanguageNegotiationInfoTest.php b/core/modules/language/lib/Drupal/language/Tests/LanguageNegotiationInfoTest.php index 70d297c..a3245ca 100644 --- a/core/modules/language/lib/Drupal/language/Tests/LanguageNegotiationInfoTest.php +++ b/core/modules/language/lib/Drupal/language/Tests/LanguageNegotiationInfoTest.php @@ -7,7 +7,7 @@ namespace Drupal\language\Tests; -use Drupal\Core\Language\Language; +use Drupal\Core\Language\LanguageInterface; use Drupal\language\Plugin\LanguageNegotiation\LanguageNegotiationUI; use Drupal\simpletest\WebTestBase; @@ -81,7 +81,7 @@ function testInfoAlterations() { 'language_test.language_types' => TRUE, // Enable language_test negotiation info (not altered yet). 'language_test.language_negotiation_info' => TRUE, - // Alter Language::TYPE_CONTENT to be configurable. + // Alter LanguageInterface::TYPE_CONTENT to be configurable. 'language_test.content_language_type' => TRUE, )); $this->container->get('module_handler')->install(array('language_test')); @@ -91,7 +91,7 @@ function testInfoAlterations() { // of saving the language negotiation settings. $this->checkFixedLanguageTypes(); - $type = Language::TYPE_CONTENT; + $type = LanguageInterface::TYPE_CONTENT; $language_types = $this->languageManager()->getLanguageTypes(); $this->assertTrue(in_array($type, $language_types), 'Content language type is configurable.'); @@ -138,7 +138,7 @@ function testInfoAlterations() { $last = $this->container->get('state')->get('language_test.language_negotiation_last'); foreach ($this->languageManager()->getDefinedLanguageTypes() as $type) { $langcode = $last[$type]; - $value = $type == Language::TYPE_CONTENT || strpos($type, 'test') !== FALSE ? 'it' : 'en'; + $value = $type == LanguageInterface::TYPE_CONTENT || strpos($type, 'test') !== FALSE ? 'it' : 'en'; $this->assertEqual($langcode, $value, format_string('The negotiated language for %type is %language', array('%type' => $type, '%language' => $value))); } diff --git a/core/modules/language/lib/Drupal/language/Tests/LanguagePathMonolingualTest.php b/core/modules/language/lib/Drupal/language/Tests/LanguagePathMonolingualTest.php index 73e5b85..7548b90 100644 --- a/core/modules/language/lib/Drupal/language/Tests/LanguagePathMonolingualTest.php +++ b/core/modules/language/lib/Drupal/language/Tests/LanguagePathMonolingualTest.php @@ -57,7 +57,7 @@ function setUp() { // Verify that French is the only language. $this->container->get('language_manager')->reset(); $this->assertFalse(\Drupal::languageManager()->isMultilingual(), 'Site is mono-lingual'); - $this->assertEqual(\Drupal::languageManager()->getDefaultLanguage()->id, 'fr', 'French is the default language'); + $this->assertEqual(\Drupal::languageManager()->getDefaultLanguage()->getId(), 'fr', 'French is the default language'); // Set language detection to URL. $edit = array('language_interface[enabled][language-url]' => TRUE); diff --git a/core/modules/language/lib/Drupal/language/Tests/LanguageSwitchingTest.php b/core/modules/language/lib/Drupal/language/Tests/LanguageSwitchingTest.php index b4c4616..d7609cc 100644 --- a/core/modules/language/lib/Drupal/language/Tests/LanguageSwitchingTest.php +++ b/core/modules/language/lib/Drupal/language/Tests/LanguageSwitchingTest.php @@ -7,7 +7,7 @@ namespace Drupal\language\Tests; -use Drupal\Core\Language\Language; +use Drupal\Core\Language\LanguageInterface; use Drupal\simpletest\WebTestBase; /** @@ -43,7 +43,7 @@ function setUp() { */ function testLanguageBlock() { // Enable the language switching block.. - $block = $this->drupalPlaceBlock('language_block:' . Language::TYPE_INTERFACE, array( + $block = $this->drupalPlaceBlock('language_block:' . LanguageInterface::TYPE_INTERFACE, array( 'id' => 'test_language_block', // Ensure a 2-byte UTF-8 sequence is in the tested output. 'label' => $this->randomName(8) . '×', diff --git a/core/modules/language/lib/Drupal/language/Tests/LanguageUILanguageNegotiationTest.php b/core/modules/language/lib/Drupal/language/Tests/LanguageUILanguageNegotiationTest.php index 1a2e5d6..743910b 100644 --- a/core/modules/language/lib/Drupal/language/Tests/LanguageUILanguageNegotiationTest.php +++ b/core/modules/language/lib/Drupal/language/Tests/LanguageUILanguageNegotiationTest.php @@ -7,6 +7,7 @@ namespace Drupal\language\Tests; +use Drupal\Core\Language\LanguageInterface; use Drupal\language\Plugin\LanguageNegotiation\LanguageNegotiationBrowser; use Drupal\language\Plugin\LanguageNegotiation\LanguageNegotiationSelected; use Drupal\language\Plugin\LanguageNegotiation\LanguageNegotiationUrl; @@ -243,7 +244,7 @@ function testUILanguageNegotiation() { // Unknown language prefix should return 404. $definitions = \Drupal::languageManager()->getNegotiator()->getNegotiationMethods(); \Drupal::config('language.types') - ->set('negotiation.' . Language::TYPE_INTERFACE . '.enabled', array_flip(array_keys($definitions))) + ->set('negotiation.' . LanguageInterface::TYPE_INTERFACE . '.enabled', array_flip(array_keys($definitions))) ->save(); $this->drupalGet("$langcode_unknown/admin/config", array(), $http_header_browser_fallback); $this->assertResponse(404, "Unknown language path prefix should return 404"); @@ -338,7 +339,7 @@ function testUILanguageNegotiation() { protected function runTest($test) { if (!empty($test['language_negotiation'])) { $method_weights = array_flip($test['language_negotiation']); - $this->container->get('language_negotiator')->saveConfiguration(Language::TYPE_INTERFACE, $method_weights); + $this->container->get('language_negotiator')->saveConfiguration(LanguageInterface::TYPE_INTERFACE, $method_weights); } if (!empty($test['language_negotiation_url_part'])) { \Drupal::config('language.negotiation') @@ -382,7 +383,7 @@ function testUrlLanguageFallback() { $this->drupalGet('admin/config/regional/language/detection'); // Enable the language switcher block. - $this->drupalPlaceBlock('language_block:' . Language::TYPE_INTERFACE, array('id' => 'test_language_block')); + $this->drupalPlaceBlock('language_block:' . LanguageInterface::TYPE_INTERFACE, array('id' => 'test_language_block')); // Log out, because for anonymous users, the "active" class is set by PHP // (which means we can easily test it here), whereas for authenticated users @@ -399,7 +400,7 @@ function testUrlLanguageFallback() { // language. $args = array(':id' => 'block-test-language-block', ':url' => base_path() . $GLOBALS['script_path'] . $langcode_browser_fallback); $fields = $this->xpath('//div[@id=:id]//a[@class="language-link active" and starts-with(@href, :url)]', $args); - $this->assertTrue($fields[0] == $languages[$langcode_browser_fallback]->name, 'The browser language is the URL active language'); + $this->assertTrue($fields[0] == $languages[$langcode_browser_fallback]->getName(), 'The browser language is the URL active language'); // Check that URLs are rewritten using the given browser language. $fields = $this->xpath('//strong[@class="site-name"]/a[@rel="home" and @href=:url]', $args); diff --git a/core/modules/language/lib/Drupal/language/Tests/LanguageUrlRewritingTest.php b/core/modules/language/lib/Drupal/language/Tests/LanguageUrlRewritingTest.php index 39ad3f8..852d75c 100644 --- a/core/modules/language/lib/Drupal/language/Tests/LanguageUrlRewritingTest.php +++ b/core/modules/language/lib/Drupal/language/Tests/LanguageUrlRewritingTest.php @@ -7,6 +7,7 @@ namespace Drupal\language\Tests; +use Drupal\Core\Language\LanguageInterface; use Drupal\language\Plugin\LanguageNegotiation\LanguageNegotiationUrl; use Drupal\simpletest\WebTestBase; use Symfony\Component\HttpFoundation\Request; @@ -55,7 +56,7 @@ function setUp() { function testUrlRewritingEdgeCases() { // Check URL rewriting with a non-installed language. $non_existing = \Drupal::languageManager()->getDefaultLanguage(); - $non_existing->id = $this->randomName(); + $non_existing->setId($this->randomName()); $this->checkUrl($non_existing, 'Path language is ignored if language is not installed.', 'URL language negotiation does not work with non-installed languages'); $request = $this->prepareRequestForGenerator(); @@ -71,14 +72,13 @@ function testUrlRewritingEdgeCases() { * check that language prefixes are not added to it and that the prefixed URL * is actually not working. * - * @param string $language - * The language prefix, e.g. 'es'. + * @param \Drupal\Core\Language\LanguageInterface $language * @param string $message1 * Message to display in assertion that language prefixes are not added. * @param string $message2 * The message to display confirming prefixed URL is not working. */ - private function checkUrl($language, $message1, $message2) { + private function checkUrl(LanguageInterface $language, $message1, $message2) { $options = array('language' => $language, 'script' => ''); $base_path = trim(base_path(), '/'); $rewritten_path = trim(str_replace($base_path, '', url('node', $options)), '/'); @@ -89,7 +89,7 @@ private function checkUrl($language, $message1, $message2) { // If the rewritten URL has not a language prefix we pick a random prefix so // we can always check the prefixed URL. $prefixes = language_negotiation_url_prefixes(); - $stored_prefix = isset($prefixes[$language->id]) ? $prefixes[$language->id] : $this->randomName(); + $stored_prefix = isset($prefixes[$language->getId()]) ? $prefixes[$language->getId()] : $this->randomName(); if ($this->assertNotEqual($stored_prefix, $prefix, $message1)) { $prefix = $stored_prefix; } diff --git a/core/modules/language/lib/Drupal/language/Tests/Views/ArgumentLanguageTest.php b/core/modules/language/lib/Drupal/language/Tests/Views/ArgumentLanguageTest.php index f25b251..83111d7 100644 --- a/core/modules/language/lib/Drupal/language/Tests/Views/ArgumentLanguageTest.php +++ b/core/modules/language/lib/Drupal/language/Tests/Views/ArgumentLanguageTest.php @@ -7,7 +7,6 @@ namespace Drupal\language\Tests\Views; -use Drupal\Core\Language\Language; use Drupal\views\Views; /** diff --git a/core/modules/language/lib/Drupal/language/Tests/Views/FieldLanguageTest.php b/core/modules/language/lib/Drupal/language/Tests/Views/FieldLanguageTest.php index 13b5135..bc082e3 100644 --- a/core/modules/language/lib/Drupal/language/Tests/Views/FieldLanguageTest.php +++ b/core/modules/language/lib/Drupal/language/Tests/Views/FieldLanguageTest.php @@ -7,7 +7,6 @@ namespace Drupal\language\Tests\Views; -use Drupal\Core\Language\Language; use Drupal\views\Views; /** diff --git a/core/modules/language/lib/Drupal/language/Tests/Views/FilterLanguageTest.php b/core/modules/language/lib/Drupal/language/Tests/Views/FilterLanguageTest.php index 87717f6..f3db7c5 100644 --- a/core/modules/language/lib/Drupal/language/Tests/Views/FilterLanguageTest.php +++ b/core/modules/language/lib/Drupal/language/Tests/Views/FilterLanguageTest.php @@ -7,7 +7,6 @@ namespace Drupal\language\Tests\Views; -use Drupal\Core\Language\Language; use Drupal\views\Views; /** diff --git a/core/modules/language/tests/Drupal/language/Tests/LanguageNegotiationUrlTest.php b/core/modules/language/tests/Drupal/language/Tests/LanguageNegotiationUrlTest.php index 6a4df28..1926cd5 100644 --- a/core/modules/language/tests/Drupal/language/Tests/LanguageNegotiationUrlTest.php +++ b/core/modules/language/tests/Drupal/language/Tests/LanguageNegotiationUrlTest.php @@ -38,13 +38,17 @@ public static function getInfo() { public function setUp() { // Set up some languages to be used by the language-based path processor. + $language_de = $this->getMock('\Drupal\Core\Language\LanguageInterface'); + $language_de->expects($this->any()) + ->method('getId') + ->will($this->returnValue('de')); + $language_en = $this->getMock('\Drupal\Core\Language\LanguageInterface'); + $language_en->expects($this->any()) + ->method('getId') + ->will($this->returnValue('en')); $languages = array( - 'de' => (object) array( - 'id' => 'de', - ), - 'en' => (object) array( - 'id' => 'en', - ), + 'de' => $language_de, + 'en' => $language_en, ); // Create a language manager stub. diff --git a/core/modules/language/tests/language_test/language_test.module b/core/modules/language/tests/language_test/language_test.module index e1fd47e..fa34a33 100644 --- a/core/modules/language/tests/language_test/language_test.module +++ b/core/modules/language/tests/language_test/language_test.module @@ -5,7 +5,7 @@ * Mock module for language layer tests. */ -use Drupal\Core\Language\Language; +use Drupal\Core\Language\LanguageInterface; use Drupal\language\Plugin\LanguageNegotiation\LanguageNegotiationUI; /** @@ -13,8 +13,8 @@ */ function language_test_page_build() { language_test_store_language_negotiation(); - if (isset(\Drupal::languageManager()->getCurrentLanguage()->id) && isset(\Drupal::languageManager()->getCurrentLanguage()->method_id)) { - drupal_set_message(t('Language negotiation method: @name', array('@name' => \Drupal::languageManager()->getCurrentLanguage()->method_id))); + if (\Drupal::languageManager()->getCurrentLanguage()->getId() && \Drupal::languageManager()->getCurrentLanguage()->getNegotiationMethodId()) { + drupal_set_message(t('Language negotiation method: @name', array('@name' => \Drupal::languageManager()->getCurrentLanguage()->getNegotiationMethodId()))); } } @@ -41,13 +41,13 @@ function language_test_language_types_info() { */ function language_test_language_types_info_alter(array &$language_types) { if (\Drupal::state()->get('language_test.content_language_type')) { - $language_types[Language::TYPE_CONTENT]['locked'] = FALSE; - unset($language_types[Language::TYPE_CONTENT]['fixed']); - // By default languages are not configurable. Make Language::TYPE_CONTENT + $language_types[LanguageInterface::TYPE_CONTENT]['locked'] = FALSE; + unset($language_types[LanguageInterface::TYPE_CONTENT]['fixed']); + // By default languages are not configurable. Make LanguageInterface::TYPE_CONTENT // configurable. $configurable = \Drupal::config('language.types')->get('configurable'); - if (!in_array(Language::TYPE_CONTENT, $configurable)) { - $configurable[] = Language::TYPE_CONTENT; + if (!in_array(LanguageInterface::TYPE_CONTENT, $configurable)) { + $configurable[] = LanguageInterface::TYPE_CONTENT; \Drupal::config('language.types')->set('configurable', $configurable)->save(); } } @@ -69,7 +69,7 @@ function language_test_store_language_negotiation() { if (\Drupal::moduleHandler()->moduleExists('language')) { $last = array(); foreach (\Drupal::languageManager()->getDefinedLanguageTypes() as $type) { - $last[$type] = \Drupal::languageManager()->getCurrentLanguage($type)->id; + $last[$type] = \Drupal::languageManager()->getCurrentLanguage($type)->getId(); } \Drupal::state()->set('language_test.language_negotiation_last', $last); } @@ -80,7 +80,7 @@ function language_test_store_language_negotiation() { */ function language_test_language_fallback_candidates_alter(array &$candidates, array $context) { if (Drupal::state()->get('language_test.fallback_alter.candidates')) { - unset($candidates[Language::LANGCODE_NOT_SPECIFIED]); + unset($candidates[LanguageInterface::LANGCODE_NOT_SPECIFIED]); } } @@ -89,7 +89,7 @@ function language_test_language_fallback_candidates_alter(array &$candidates, ar */ function language_test_language_fallback_candidates_test_alter(array &$candidates, array $context) { if (Drupal::state()->get('language_test.fallback_operation_alter.candidates')) { - $langcode = Language::LANGCODE_NOT_APPLICABLE; + $langcode = LanguageInterface::LANGCODE_NOT_APPLICABLE; $candidates[$langcode] = $langcode; } } diff --git a/core/modules/language/tests/language_test/lib/Drupal/language_test/Plugin/LanguageNegotiation/LanguageNegotiationTest.php b/core/modules/language/tests/language_test/lib/Drupal/language_test/Plugin/LanguageNegotiation/LanguageNegotiationTest.php index a726c5c..61b02c1 100644 --- a/core/modules/language/tests/language_test/lib/Drupal/language_test/Plugin/LanguageNegotiation/LanguageNegotiationTest.php +++ b/core/modules/language/tests/language_test/lib/Drupal/language_test/Plugin/LanguageNegotiation/LanguageNegotiationTest.php @@ -18,7 +18,7 @@ * weight = -10, * name = @Translation("Test"), * description = @Translation("This is a test language negotiation method."), - * types = {Drupal\Core\Language\Language::TYPE_CONTENT, "test_language_type", "fixed_test_language_type"} + * types = {Drupal\Core\Language\LanguageInterface::TYPE_CONTENT, "test_language_type", "fixed_test_language_type"} * ) */ class LanguageNegotiationTest extends LanguageNegotiationMethodBase { diff --git a/core/modules/locale/lib/Drupal/locale/Form/ExportForm.php b/core/modules/locale/lib/Drupal/locale/Form/ExportForm.php index 433c8c9..89adf49 100644 --- a/core/modules/locale/lib/Drupal/locale/Form/ExportForm.php +++ b/core/modules/locale/lib/Drupal/locale/Form/ExportForm.php @@ -9,7 +9,7 @@ use Drupal\Component\Gettext\PoStreamWriter; use Drupal\Core\Form\FormBase; -use Drupal\Core\Language\Language; +use Drupal\Core\Language\LanguageInterface; use Drupal\Core\Language\LanguageManagerInterface; use Drupal\locale\PoDatabaseReader; use Symfony\Component\DependencyInjection\ContainerInterface; @@ -61,7 +61,7 @@ public function buildForm(array $form, array &$form_state) { $language_options = array(); foreach ($languages as $langcode => $language) { if ($langcode != 'en' || locale_translate_english()) { - $language_options[$langcode] = $language->name; + $language_options[$langcode] = $language->getName(); } } $language_default = $this->languageManager->getDefaultLanguage(); @@ -69,7 +69,7 @@ public function buildForm(array $form, array &$form_state) { if (empty($language_options)) { $form['langcode'] = array( '#type' => 'value', - '#value' => Language::LANGCODE_SYSTEM, + '#value' => LanguageInterface::LANGCODE_SYSTEM, ); $form['langcode_text'] = array( '#type' => 'item', @@ -82,9 +82,9 @@ public function buildForm(array $form, array &$form_state) { '#type' => 'select', '#title' => $this->t('Language'), '#options' => $language_options, - '#default_value' => $language_default->id, + '#default_value' => $language_default->getId(), '#empty_option' => $this->t('Source text only, no translations'), - '#empty_value' => Language::LANGCODE_SYSTEM, + '#empty_value' => LanguageInterface::LANGCODE_SYSTEM, ); $form['content_options'] = array( '#type' => 'details', @@ -93,7 +93,7 @@ public function buildForm(array $form, array &$form_state) { '#tree' => TRUE, '#states' => array( 'invisible' => array( - ':input[name="langcode"]' => array('value' => Language::LANGCODE_SYSTEM), + ':input[name="langcode"]' => array('value' => LanguageInterface::LANGCODE_SYSTEM), ), ), ); @@ -129,7 +129,7 @@ public function buildForm(array $form, array &$form_state) { */ public function submitForm(array &$form, array &$form_state) { // If template is required, language code is not given. - if ($form_state['values']['langcode'] != Language::LANGCODE_SYSTEM) { + if ($form_state['values']['langcode'] != LanguageInterface::LANGCODE_SYSTEM) { $language = $this->languageManager->getLanguage($form_state['values']['langcode']); } else { @@ -139,11 +139,11 @@ public function submitForm(array &$form, array &$form_state) { $reader = new PoDatabaseReader(); $languageName = ''; if ($language != NULL) { - $reader->setLangcode($language->id); + $reader->setLangcode($language->getId()); $reader->setOptions($content_options); $languages = $this->languageManager->getLanguages(); - $languageName = isset($languages[$language->id]) ? $languages[$language->id]->name : ''; - $filename = $language->id .'.po'; + $languageName = isset($languages[$language->getId()]) ? $languages[$language->getId()]->getName() : ''; + $filename = $language->getId() .'.po'; } else { // Template required. diff --git a/core/modules/locale/lib/Drupal/locale/Form/ImportForm.php b/core/modules/locale/lib/Drupal/locale/Form/ImportForm.php index 21b3150..e22cb52 100644 --- a/core/modules/locale/lib/Drupal/locale/Form/ImportForm.php +++ b/core/modules/locale/lib/Drupal/locale/Form/ImportForm.php @@ -81,7 +81,7 @@ public function buildForm(array $form, array &$form_state) { $existing_languages = array(); foreach ($languages as $langcode => $language) { if ($langcode != 'en' || locale_translate_english()) { - $existing_languages[$langcode] = $language->name; + $existing_languages[$langcode] = $language->getName(); } } @@ -179,7 +179,7 @@ public function submitForm(array &$form, array &$form_state) { 'id' => $form_state['values']['langcode'] )); $language = language_save($language); - drupal_set_message($this->t('The language %language has been created.', array('%language' => $this->t($language->name)))); + drupal_set_message($this->t('The language %language has been created.', array('%language' => $this->t($language->getName())))); } $options = array( 'langcode' => $form_state['values']['langcode'], diff --git a/core/modules/locale/lib/Drupal/locale/Form/TranslateEditForm.php b/core/modules/locale/lib/Drupal/locale/Form/TranslateEditForm.php index c846026..24066a4 100644 --- a/core/modules/locale/lib/Drupal/locale/Form/TranslateEditForm.php +++ b/core/modules/locale/lib/Drupal/locale/Form/TranslateEditForm.php @@ -33,7 +33,7 @@ public function buildForm(array $form, array &$form_state) { $this->languageManager->reset(); $languages = language_list(); - $langname = isset($langcode) ? $languages[$langcode]->name : "- None -"; + $langname = isset($langcode) ? $languages[$langcode]->getName() : "- None -"; $form['#attached']['library'][] = 'locale/drupal.locale.admin'; diff --git a/core/modules/locale/lib/Drupal/locale/Form/TranslateFormBase.php b/core/modules/locale/lib/Drupal/locale/Form/TranslateFormBase.php index 24b378e..9d1a4d1 100644 --- a/core/modules/locale/lib/Drupal/locale/Form/TranslateFormBase.php +++ b/core/modules/locale/lib/Drupal/locale/Form/TranslateFormBase.php @@ -8,7 +8,6 @@ namespace Drupal\locale\Form; use Drupal\Core\Form\FormBase; -use Drupal\Core\Language\Language; use Drupal\Core\Language\LanguageManager; use Drupal\locale\StringStorageInterface; use Drupal\Core\State\StateInterface; @@ -166,12 +165,12 @@ protected function translateFilters() { $language_options = array(); foreach ($languages as $langcode => $language) { if ($langcode != 'en' || locale_translate_english()) { - $language_options[$langcode] = $language->name; + $language_options[$langcode] = $language->getName(); } } // Pick the current interface language code for the filter. - $default_langcode = $this->languageManager->getCurrentLanguage()->id; + $default_langcode = $this->languageManager->getCurrentLanguage()->getId(); if (!isset($language_options[$default_langcode])) { $available_langcodes = array_keys($language_options); $default_langcode = array_shift($available_langcodes); diff --git a/core/modules/locale/lib/Drupal/locale/LocaleConfigManager.php b/core/modules/locale/lib/Drupal/locale/LocaleConfigManager.php index 3c0dc57..5ff5175 100644 --- a/core/modules/locale/lib/Drupal/locale/LocaleConfigManager.php +++ b/core/modules/locale/lib/Drupal/locale/LocaleConfigManager.php @@ -8,10 +8,10 @@ namespace Drupal\locale; use Drupal\Core\Cache\CacheBackendInterface; -use Drupal\Core\Language\Language; use Drupal\Core\Config\TypedConfigManager; use Drupal\Core\Config\StorageInterface; use Drupal\Core\Config\ConfigFactoryInterface; +use Drupal\Core\Language\LanguageInterface; use Drupal\language\Config\LanguageConfigFactoryOverrideInterface; use Drupal\language\ConfigurableLanguageManagerInterface; @@ -308,14 +308,14 @@ public function translateString($name, $langcode, $source, $context) { * * @param string $name * Configuration name. - * @param \Drupal\Core\Language\Language $language + * @param \Drupal\Core\Language\LanguageInterface $language * A language object. * * @return bool * A boolean indicating if a language has configuration translations. */ - public function hasTranslation($name, Language $language) { - $translation = $this->languageManager->getLanguageConfigOverride($language->id, $name); + public function hasTranslation($name, LanguageInterface $language) { + $translation = $this->languageManager->getLanguageConfigOverride($language->getId(), $name); return !$translation->isNew(); } diff --git a/core/modules/locale/lib/Drupal/locale/LocaleTranslation.php b/core/modules/locale/lib/Drupal/locale/LocaleTranslation.php index 63abc07..d9a9800 100644 --- a/core/modules/locale/lib/Drupal/locale/LocaleTranslation.php +++ b/core/modules/locale/lib/Drupal/locale/LocaleTranslation.php @@ -10,7 +10,7 @@ use Drupal\Core\Cache\CacheBackendInterface; use Drupal\Core\Config\ConfigFactoryInterface; use Drupal\Core\DestructableInterface; -use Drupal\Core\Language\Language; +use Drupal\Core\Language\LanguageInterface; use Drupal\Core\Language\LanguageManagerInterface; use Drupal\Core\Lock\LockBackendInterface; use Drupal\Core\StringTranslation\Translator\TranslatorInterface; @@ -101,7 +101,7 @@ public function __construct(StringStorageInterface $storage, CacheBackendInterfa */ public function getStringTranslation($langcode, $string, $context) { // If the language is not suitable for locale module, just return. - if ($langcode == Language::LANGCODE_SYSTEM || ($langcode == 'en' && !$this->canTranslateEnglish())) { + if ($langcode == LanguageInterface::LANGCODE_SYSTEM || ($langcode == 'en' && !$this->canTranslateEnglish())) { return FALSE; } // Strings are cached by langcode, context and roles, using instances of the diff --git a/core/modules/locale/lib/Drupal/locale/LocaleTypedConfig.php b/core/modules/locale/lib/Drupal/locale/LocaleTypedConfig.php index c0095f1..dd24d99 100644 --- a/core/modules/locale/lib/Drupal/locale/LocaleTypedConfig.php +++ b/core/modules/locale/lib/Drupal/locale/LocaleTypedConfig.php @@ -7,7 +7,6 @@ namespace Drupal\locale; -use Drupal\Core\Language\Language; use Drupal\Core\TypedData\ContextAwareInterface; use Drupal\Core\Config\Schema\Element; use Drupal\Core\Config\Schema\ArrayElement; diff --git a/core/modules/locale/lib/Drupal/locale/Tests/LocaleConfigTranslationTest.php b/core/modules/locale/lib/Drupal/locale/Tests/LocaleConfigTranslationTest.php index a4ee53a..8a630eb 100644 --- a/core/modules/locale/lib/Drupal/locale/Tests/LocaleConfigTranslationTest.php +++ b/core/modules/locale/lib/Drupal/locale/Tests/LocaleConfigTranslationTest.php @@ -7,7 +7,6 @@ namespace Drupal\locale\Tests; -use Drupal\Core\Language\Language; use Drupal\simpletest\WebTestBase; use Drupal\locale\LocaleTypedConfig; diff --git a/core/modules/locale/lib/Drupal/locale/Tests/LocalePathTest.php b/core/modules/locale/lib/Drupal/locale/Tests/LocalePathTest.php index cae7f4b..ef99bec 100644 --- a/core/modules/locale/lib/Drupal/locale/Tests/LocalePathTest.php +++ b/core/modules/locale/lib/Drupal/locale/Tests/LocalePathTest.php @@ -7,7 +7,7 @@ namespace Drupal\locale\Tests; -use Drupal\Core\Language\Language; +use Drupal\Core\Language\LanguageInterface; use Drupal\simpletest\WebTestBase; /** @@ -106,7 +106,7 @@ function testPathLanguageConfiguration() { $edit = array( 'source' => 'node/' . $node->id(), 'alias' => $custom_path, - 'langcode' => Language::LANGCODE_NOT_SPECIFIED, + 'langcode' => LanguageInterface::LANGCODE_NOT_SPECIFIED, ); $this->container->get('path.alias_storage')->save($edit['source'], $edit['alias'], $edit['langcode']); $lookup_path = $this->container->get('path.alias_manager')->getAliasByPath('node/' . $node->id(), 'en'); @@ -118,21 +118,21 @@ function testPathLanguageConfiguration() { // Create language nodes to check priority of aliases. $first_node = $this->drupalCreateNode(array('type' => 'page', 'promote' => 1, 'langcode' => 'en')); - $second_node = $this->drupalCreateNode(array('type' => 'page', 'promote' => 1, 'langcode' => Language::LANGCODE_NOT_SPECIFIED)); + $second_node = $this->drupalCreateNode(array('type' => 'page', 'promote' => 1, 'langcode' => LanguageInterface::LANGCODE_NOT_SPECIFIED)); // Assign a custom path alias to the first node with the English language. $edit = array( 'source' => 'node/' . $first_node->id(), 'alias' => $custom_path, - 'langcode' => $first_node->language()->id, + 'langcode' => $first_node->language()->getId(), ); $this->container->get('path.alias_storage')->save($edit['source'], $edit['alias'], $edit['langcode']); - // Assign a custom path alias to second node with Language::LANGCODE_NOT_SPECIFIED. + // Assign a custom path alias to second node with LanguageInterface::LANGCODE_NOT_SPECIFIED. $edit = array( 'source' => 'node/' . $second_node->id(), 'alias' => $custom_path, - 'langcode' => $second_node->language()->id, + 'langcode' => $second_node->language()->getId(), ); $this->container->get('path.alias_storage')->save($edit['source'], $edit['alias'], $edit['langcode']); diff --git a/core/modules/locale/lib/Drupal/locale/Tests/LocaleStringTest.php b/core/modules/locale/lib/Drupal/locale/Tests/LocaleStringTest.php index a9b45ec..151a40f 100644 --- a/core/modules/locale/lib/Drupal/locale/Tests/LocaleStringTest.php +++ b/core/modules/locale/lib/Drupal/locale/Tests/LocaleStringTest.php @@ -193,8 +193,10 @@ function buildSourceString($values = array()) { */ function createAllTranslations($source, $values = array()) { $list = array(); - foreach ($this->container->get('language_manager')->getLanguages() as $language) { - $list[$language->id] = $this->createTranslation($source, $language->id, $values); + /** @var \Drupal\Core\Language\LanguageManagerInterface $language_manager */ + $language_manager = $this->container->get('language_manager'); + foreach ($language_manager->getLanguages() as $language) { + $list[$language->getId()] = $this->createTranslation($source, $language->getId(), $values); } return $list; } diff --git a/core/modules/locale/lib/Drupal/locale/Tests/LocaleTranslationUiTest.php b/core/modules/locale/lib/Drupal/locale/Tests/LocaleTranslationUiTest.php index fa33010..33051f9 100644 --- a/core/modules/locale/lib/Drupal/locale/Tests/LocaleTranslationUiTest.php +++ b/core/modules/locale/lib/Drupal/locale/Tests/LocaleTranslationUiTest.php @@ -8,6 +8,7 @@ namespace Drupal\locale\Tests; use Drupal\Core\Cache\Cache; +use Drupal\Core\Language\LanguageInterface; use Drupal\simpletest\WebTestBase; use Drupal\Core\Language\Language; use Drupal\Component\Utility\String; @@ -152,7 +153,7 @@ function testStringTranslation() { $this->container->get('string_translation')->reset(); // Now we should get the proper fresh translation from t(). $this->assertTrue($name != $translation_to_en && t($name, array(), array('langcode' => 'en')) == $translation_to_en, 't() works for English.'); - $this->assertTrue(t($name, array(), array('langcode' => Language::LANGCODE_SYSTEM)) == $name, 't() works for Language::LANGCODE_SYSTEM.'); + $this->assertTrue(t($name, array(), array('langcode' => LanguageInterface::LANGCODE_SYSTEM)) == $name, 't() works for LanguageInterface::LANGCODE_SYSTEM.'); $search = array( 'string' => $name, diff --git a/core/modules/locale/locale.bulk.inc b/core/modules/locale/locale.bulk.inc index 06c0887..0ccb4cd 100644 --- a/core/modules/locale/locale.bulk.inc +++ b/core/modules/locale/locale.bulk.inc @@ -6,7 +6,7 @@ */ use Drupal\locale\Gettext; -use Drupal\Core\Language\Language; +use Drupal\Core\Language\LanguageInterface; use Drupal\file\FileInterface; /** @@ -167,7 +167,7 @@ function locale_translate_batch_build($files, $options) { * * @param object $file * A file object of the gettext file to be imported. The file object must - * contain a language parameter (other than Language::LANGCODE_NOT_SPECIFIED). This + * contain a language parameter (other than LanguageInterface::LANGCODE_NOT_SPECIFIED). This * is used as the language of the import. * * @param array $options @@ -192,7 +192,7 @@ function locale_translate_batch_import($file, $options, &$context) { 'customized' => LOCALE_NOT_CUSTOMIZED, ); - if (isset($file->langcode) && $file->langcode != Language::LANGCODE_NOT_SPECIFIED) { + if (isset($file->langcode) && $file->langcode != LanguageInterface::LANGCODE_NOT_SPECIFIED) { try { if (empty($context['sandbox'])) { @@ -459,7 +459,7 @@ function locale_translate_file_attach_properties($file, $options = array()) { $file->langcode = isset($options['langcode']) ? $options['langcode'] : $matches[5]; } else { - $file->langcode = Language::LANGCODE_NOT_SPECIFIED; + $file->langcode = LanguageInterface::LANGCODE_NOT_SPECIFIED; } return $file; } diff --git a/core/modules/locale/locale.install b/core/modules/locale/locale.install index c62c842..29c0657 100644 --- a/core/modules/locale/locale.install +++ b/core/modules/locale/locale.install @@ -5,7 +5,6 @@ * Install, update, and uninstall functions for the Locale module. */ -use Drupal\Core\Language\Language; use Drupal\language\Plugin\LanguageNegotiation\LanguageNegotiationSelected; /** diff --git a/core/modules/locale/locale.module b/core/modules/locale/locale.module index d3e05dc..97bb3a9 100644 --- a/core/modules/locale/locale.module +++ b/core/modules/locale/locale.module @@ -14,7 +14,7 @@ use Drupal\Component\Utility\UrlHelper; use Drupal\Component\Utility\Xss; use Drupal\Core\Cache\Cache; -use Drupal\Core\Language\Language; +use Drupal\Core\Language\LanguageInterface; use Drupal\language\Entity\Language as LanguageEntity; use Drupal\Component\Utility\Crypt; use Symfony\Component\HttpFoundation\Request; @@ -303,7 +303,7 @@ function locale_get_plural($count, $langcode = NULL) { // individually for each language. $plural_indexes = &drupal_static(__FUNCTION__ . ':plurals', array()); - $langcode = $langcode ? $langcode : $language_interface->id; + $langcode = $langcode ? $langcode : $language_interface->getId(); if (!isset($plural_indexes[$langcode][$count])) { // Retrieve and statically cache the plural formulas for all languages. @@ -590,11 +590,11 @@ function locale_js_translate(array $files = array()) { } // If necessary, rebuild the translation file for the current language. - if (!empty($parsed['refresh:' . $language_interface->id])) { + if (!empty($parsed['refresh:' . $language_interface->getId()])) { // Don't clear the refresh flag on failure, so that another try will // be performed later. if (_locale_rebuild_js()) { - unset($parsed['refresh:' . $language_interface->id]); + unset($parsed['refresh:' . $language_interface->getId()]); } // Store any changes after refresh was attempted. \Drupal::state()->set('system.javascript_parsed', $parsed); @@ -608,9 +608,9 @@ function locale_js_translate(array $files = array()) { // Add the translation JavaScript file to the page. $locale_javascripts = \Drupal::state()->get('locale.translation.javascript') ?: array(); $translation_file = NULL; - if (!empty($files) && !empty($locale_javascripts[$language_interface->id])) { + if (!empty($files) && !empty($locale_javascripts[$language_interface->getId()])) { // Add the translation JavaScript file to the page. - $translation_file = $dir . '/' . $language_interface->id . '_' . $locale_javascripts[$language_interface->id] . '.js'; + $translation_file = $dir . '/' . $language_interface->getId() . '_' . $locale_javascripts[$language_interface->getId()] . '.js'; } return $translation_file; } @@ -628,7 +628,7 @@ function locale_library_alter(array &$library, $name) { $language_interface = \Drupal::languageManager()->getCurrentLanguage(); $settings['jquery']['ui']['datepicker'] = array( - 'isRTL' => $language_interface->direction == Language::DIRECTION_RTL, + 'isRTL' => $language_interface->getDirection() == LanguageInterface::DIRECTION_RTL, 'firstDay' => \Drupal::config('system.date')->get('first_day'), ); $library['js'][] = array( @@ -801,20 +801,22 @@ function locale_system_file_system_settings_submit(&$form, $form_state) { * Implements hook_preprocess_HOOK() for node templates. */ function locale_preprocess_node(&$variables) { - if ($variables['node']->language()->id != Language::LANGCODE_NOT_SPECIFIED) { + /** @var \Drupal\node\NodeInterface $node */ + $node = $variables['node']; + if ($node->language()->getId() != LanguageInterface::LANGCODE_NOT_SPECIFIED) { $language_interface = \Drupal::languageManager()->getCurrentLanguage(); - $node_language = $variables['node']->language(); - if ($node_language->id != $language_interface->id) { + $node_language = $node->language(); + if ($node_language->getId() != $language_interface->getId()) { // If the node language was different from the page language, we should // add markup to identify the language. Otherwise the page language is // inherited. - $variables['attributes']['lang'] = $node_language->id; - if ($node_language->direction != $language_interface->direction) { + $variables['attributes']['lang'] = $node_language->getId(); + if ($node_language->getDirection() != $language_interface->getDirection()) { // If text direction is different form the page's text direction, add // direction information as well. $dir = array('ltr', 'rtl'); - $variables['attributes']['dir'] = $dir[$node_language->direction]; + $variables['attributes']['dir'] = $dir[$node_language->getDirection()]; } } } @@ -1266,7 +1268,7 @@ function _locale_rebuild_js($langcode = NULL) { // Only add strings with a translation to the translations array. $conditions = array( 'type' => 'javascript', - 'language' => $language->id, + 'language' => $language->getId(), 'translated' => TRUE, ); $translations = array(); @@ -1283,8 +1285,8 @@ function _locale_rebuild_js($langcode = NULL) { ); $locale_plurals = \Drupal::state()->get('locale.translation.plurals') ?: array(); - if (!empty($locale_plurals[$language->id]['formula'])) { - $data['pluralFormula'] = $locale_plurals[$language->id]['formula']; + if (!empty($locale_plurals[$language->getId()]['formula'])) { + $data['pluralFormula'] = $locale_plurals[$language->getId()]['formula']; } $data = 'Drupal.locale = ' . Json::encode($data) . ';'; @@ -1297,23 +1299,23 @@ function _locale_rebuild_js($langcode = NULL) { // Delete old file, if we have no translations anymore, or a different file to be saved. $locale_javascripts = \Drupal::state()->get('locale.translation.javascript') ?: array(); - $changed_hash = !isset($locale_javascripts[$language->id]) || ($locale_javascripts[$language->id] != $data_hash); - if (!empty($locale_javascripts[$language->id]) && (!$data || $changed_hash)) { - file_unmanaged_delete($dir . '/' . $language->id . '_' . $locale_javascripts[$language->id] . '.js'); - $locale_javascripts[$language->id] = ''; + $changed_hash = !isset($locale_javascripts[$language->getId()]) || ($locale_javascripts[$language->getId()] != $data_hash); + if (!empty($locale_javascripts[$language->getId()]) && (!$data || $changed_hash)) { + file_unmanaged_delete($dir . '/' . $language->getId() . '_' . $locale_javascripts[$language->getId()] . '.js'); + $locale_javascripts[$language->getId()] = ''; $status = 'deleted'; } // Only create a new file if the content has changed or the original file got // lost. - $dest = $dir . '/' . $language->id . '_' . $data_hash . '.js'; + $dest = $dir . '/' . $language->getId() . '_' . $data_hash . '.js'; if ($data && ($changed_hash || !file_exists($dest))) { // Ensure that the directory exists and is writable, if possible. file_prepare_directory($dir, FILE_CREATE_DIRECTORY); // Save the file. if (file_unmanaged_save_data($data, $dest)) { - $locale_javascripts[$language->id] = $data_hash; + $locale_javascripts[$language->getId()] = $data_hash; // If we deleted a previous version of the file and we replace it with a // new one we have an update. if ($status == 'deleted') { @@ -1331,7 +1333,7 @@ function _locale_rebuild_js($langcode = NULL) { } } else { - $locale_javascripts[$language->id] = ''; + $locale_javascripts[$language->getId()] = ''; $status = 'error'; } } @@ -1346,21 +1348,21 @@ function _locale_rebuild_js($langcode = NULL) { // Log the operation and return success flag. switch ($status) { case 'updated': - watchdog('locale', 'Updated JavaScript translation file for the language %language.', array('%language' => $language->name)); + watchdog('locale', 'Updated JavaScript translation file for the language %language.', array('%language' => $language->getName())); return TRUE; case 'rebuilt': - watchdog('locale', 'JavaScript translation file %file.js was lost.', array('%file' => $locale_javascripts[$language->id]), WATCHDOG_WARNING); + watchdog('locale', 'JavaScript translation file %file.js was lost.', array('%file' => $locale_javascripts[$language->getId()]), WATCHDOG_WARNING); // Proceed to the 'created' case as the JavaScript translation file has // been created again. case 'created': - watchdog('locale', 'Created JavaScript translation file for the language %language.', array('%language' => $language->name)); + watchdog('locale', 'Created JavaScript translation file for the language %language.', array('%language' => $language->getName())); return TRUE; case 'deleted': - watchdog('locale', 'Removed JavaScript translation file for the language %language because no translations currently exist for that language.', array('%language' => $language->name)); + watchdog('locale', 'Removed JavaScript translation file for the language %language because no translations currently exist for that language.', array('%language' => $language->getName())); return TRUE; case 'error': - watchdog('locale', 'An error occurred during creation of the JavaScript translation file for the language %language.', array('%language' => $language->name), WATCHDOG_ERROR); + watchdog('locale', 'An error occurred during creation of the JavaScript translation file for the language %language.', array('%language' => $language->getName()), WATCHDOG_ERROR); return FALSE; default: // No operation needed. diff --git a/core/modules/locale/locale.pages.inc b/core/modules/locale/locale.pages.inc index c35e33a..f7f6111 100644 --- a/core/modules/locale/locale.pages.inc +++ b/core/modules/locale/locale.pages.inc @@ -6,7 +6,6 @@ */ use Drupal\Component\Utility\String; -use Drupal\Core\Language\Language; use Drupal\Core\Render\Element; use Drupal\locale\SourceString; use Drupal\locale\TranslationString; @@ -92,7 +91,7 @@ function locale_translation_status_form($form, &$form_state) { // Build data options for the select table. foreach($updates as $langcode => $update) { - $title = String::checkPlain($languages[$langcode]->name); + $title = String::checkPlain($languages[$langcode]->getName()); $locale_translation_update_info = array('#theme' => 'locale_translation_update_info'); foreach (array('updates', 'not_found') as $update_status) { if (isset($update[$update_status])) { diff --git a/core/modules/menu_link/lib/Drupal/menu_link/MenuLinkForm.php b/core/modules/menu_link/lib/Drupal/menu_link/MenuLinkForm.php index c365dae..c3f1be2 100644 --- a/core/modules/menu_link/lib/Drupal/menu_link/MenuLinkForm.php +++ b/core/modules/menu_link/lib/Drupal/menu_link/MenuLinkForm.php @@ -9,7 +9,7 @@ use Drupal\Component\Utility\UrlHelper; use Drupal\Core\Entity\EntityForm; -use Drupal\Core\Language\Language; +use Drupal\Core\Language\LanguageInterface; use Drupal\Core\Path\AliasManagerInterface; use Drupal\Core\Routing\UrlGenerator; use Symfony\Component\DependencyInjection\ContainerInterface; @@ -181,7 +181,7 @@ public function form(array $form, array &$form_state) { $form['langcode'] = array( '#type' => 'language_select', '#title' => t('Language'), - '#languages' => Language::STATE_ALL, + '#languages' => LanguageInterface::STATE_ALL, '#default_value' => $default_langcode, '#access' => $language_show, ); diff --git a/core/modules/menu_link/lib/Drupal/menu_link/MenuTree.php b/core/modules/menu_link/lib/Drupal/menu_link/MenuTree.php index adbf85d..e54abb8 100644 --- a/core/modules/menu_link/lib/Drupal/menu_link/MenuTree.php +++ b/core/modules/menu_link/lib/Drupal/menu_link/MenuTree.php @@ -155,7 +155,7 @@ public function buildAllData($menu_name, $link = NULL, $max_depth = NULL) { $mlid = isset($link['mlid']) ? $link['mlid'] : 0; // Generate a cache ID (cid) specific for this $menu_name, $link, $language, // and depth. - $cid = 'links:' . $menu_name . ':all:' . $mlid . ':' . $language_interface->id . ':' . (int) $max_depth; + $cid = 'links:' . $menu_name . ':all:' . $mlid . ':' . $language_interface->getId() . ':' . (int) $max_depth; if (!isset($this->menuFullTrees[$cid])) { // If the static variable doesn't have the data, check {cache_menu}. @@ -218,7 +218,7 @@ public function buildPageData($menu_name, $max_depth = NULL, $only_active_trail $max_depth = min($max_depth, MENU_MAX_DEPTH); } // Generate a cache ID (cid) specific for this page. - $cid = 'links:' . $menu_name . ':page:' . $system_path . ':' . $language_interface->id . ':' . $page_not_403 . ':' . (int) $max_depth; + $cid = 'links:' . $menu_name . ':page:' . $system_path . ':' . $language_interface->getId() . ':' . $page_not_403 . ':' . (int) $max_depth; // If we are asked for the active trail only, and $menu_name has not been // built and cached for this page yet, then this likely means that it // won't be built anymore, as this function is invoked from @@ -454,7 +454,7 @@ protected function doBuildTree($menu_name, array $parameters = array()) { if (isset($parameters['expanded'])) { sort($parameters['expanded']); } - $tree_cid = 'links:' . $menu_name . ':tree-data:' . $language_interface->id . ':' . hash('sha256', serialize($parameters)); + $tree_cid = 'links:' . $menu_name . ':tree-data:' . $language_interface->getId() . ':' . hash('sha256', serialize($parameters)); // If we do not have this tree in the static cache, check {cache_menu}. if (!isset($this->menuTree[$tree_cid])) { diff --git a/core/modules/menu_ui/lib/Drupal/menu_ui/MenuForm.php b/core/modules/menu_ui/lib/Drupal/menu_ui/MenuForm.php index a796f66..6b5333c 100644 --- a/core/modules/menu_ui/lib/Drupal/menu_ui/MenuForm.php +++ b/core/modules/menu_ui/lib/Drupal/menu_ui/MenuForm.php @@ -10,7 +10,7 @@ use Drupal\Component\Utility\NestedArray; use Drupal\Core\Entity\EntityForm; use Drupal\Core\Entity\Query\QueryFactory; -use Drupal\Core\Language\Language; +use Drupal\Core\Language\LanguageInterface; use Drupal\Core\Render\Element; use Drupal\menu_link\MenuLinkStorageInterface; use Drupal\menu_link\MenuTreeInterface; @@ -117,7 +117,7 @@ public function form(array $form, array &$form_state) { $form['langcode'] = array( '#type' => 'language_select', '#title' => t('Menu language'), - '#languages' => Language::STATE_ALL, + '#languages' => LanguageInterface::STATE_ALL, '#default_value' => $menu->langcode, ); // Unlike the menu langcode, the default language configuration for menu diff --git a/core/modules/menu_ui/lib/Drupal/menu_ui/Tests/MenuLanguageTest.php b/core/modules/menu_ui/lib/Drupal/menu_ui/Tests/MenuLanguageTest.php index 73374aa..9e6f519 100644 --- a/core/modules/menu_ui/lib/Drupal/menu_ui/Tests/MenuLanguageTest.php +++ b/core/modules/menu_ui/lib/Drupal/menu_ui/Tests/MenuLanguageTest.php @@ -180,7 +180,7 @@ function testMenuLanguageRemovedEnglish() { // Remove English language. To do that another language has to be set as // default. $language = language_load('cs'); - $language->default = TRUE; + $language->setDefault(TRUE); language_save($language); language_delete('en'); diff --git a/core/modules/migrate/lib/Drupal/migrate/Plugin/migrate/process/MachineName.php b/core/modules/migrate/lib/Drupal/migrate/Plugin/migrate/process/MachineName.php index 80532bc..9af3fdc 100644 --- a/core/modules/migrate/lib/Drupal/migrate/Plugin/migrate/process/MachineName.php +++ b/core/modules/migrate/lib/Drupal/migrate/Plugin/migrate/process/MachineName.php @@ -7,7 +7,7 @@ namespace Drupal\migrate\Plugin\migrate\process; -use Drupal\Core\Language\Language; +use Drupal\Core\Language\LanguageInterface; use Drupal\migrate\ProcessPluginBase; use Drupal\migrate\MigrateExecutable; use Drupal\migrate\Row; @@ -34,7 +34,7 @@ class MachineName extends ProcessPluginBase { * {@inheritdoc} */ public function transform($value, MigrateExecutable $migrate_executable, Row $row, $destination_property) { - $new_value = $this->getTransliteration()->transliterate($value, Language::LANGCODE_DEFAULT, '_'); + $new_value = $this->getTransliteration()->transliterate($value, LanguageInterface::LANGCODE_DEFAULT, '_'); $new_value = strtolower($new_value); $new_value = preg_replace('/[^a-z0-9_]+/', '_', $new_value); return preg_replace('/_+/', '_', $new_value); diff --git a/core/modules/migrate_drupal/lib/Drupal/migrate_drupal/Tests/d6/MigrateAggregatorFeedTest.php b/core/modules/migrate_drupal/lib/Drupal/migrate_drupal/Tests/d6/MigrateAggregatorFeedTest.php index 1110f72..3b4cfc2 100644 --- a/core/modules/migrate_drupal/lib/Drupal/migrate_drupal/Tests/d6/MigrateAggregatorFeedTest.php +++ b/core/modules/migrate_drupal/lib/Drupal/migrate_drupal/Tests/d6/MigrateAggregatorFeedTest.php @@ -8,7 +8,7 @@ namespace Drupal\migrate_drupal\Tests\d6; use Drupal\aggregator\Entity\Feed; -use Drupal\Core\Language\Language; +use Drupal\Core\Language\LanguageInterface; use Drupal\migrate\MigrateExecutable; use Drupal\migrate_drupal\Tests\MigrateDrupalTestBase; @@ -52,7 +52,7 @@ public function testAggregatorFeedImport() { $feed = entity_load('aggregator_feed', 5); $this->assertNotNull($feed->uuid()); $this->assertEqual($feed->title->value, 'Know Your Meme'); - $this->assertEqual($feed->language()->id, Language::LANGCODE_NOT_SPECIFIED); + $this->assertEqual($feed->language()->getId(), LanguageInterface::LANGCODE_NOT_SPECIFIED); $this->assertEqual($feed->url->value, 'http://knowyourmeme.com/newsfeed.rss'); $this->assertEqual($feed->refresh->value, 900); $this->assertEqual($feed->checked->value, 1387659487); diff --git a/core/modules/migrate_drupal/lib/Drupal/migrate_drupal/Tests/d6/MigrateAggregatorItemTest.php b/core/modules/migrate_drupal/lib/Drupal/migrate_drupal/Tests/d6/MigrateAggregatorItemTest.php index c5ca816..c08890b 100644 --- a/core/modules/migrate_drupal/lib/Drupal/migrate_drupal/Tests/d6/MigrateAggregatorItemTest.php +++ b/core/modules/migrate_drupal/lib/Drupal/migrate_drupal/Tests/d6/MigrateAggregatorItemTest.php @@ -8,7 +8,7 @@ namespace Drupal\migrate_drupal\Tests\d6; use Drupal\aggregator\Entity\Item; -use Drupal\Core\Language\Language; +use Drupal\Core\Language\LanguageInterface; use Drupal\migrate\MigrateExecutable; use Drupal\migrate_drupal\Tests\MigrateDrupalTestBase; @@ -76,7 +76,7 @@ public function testAggregatorItem() { $this->assertEqual($item->getDescription(), "

What's new with Drupal 8?

"); $this->assertEqual($item->getLink(), 'https://groups.drupal.org/node/395218'); $this->assertEqual($item->getPostedTime(), 1389297196); - $this->assertEqual($item->language()->id, Language::LANGCODE_NOT_SPECIFIED); + $this->assertEqual($item->language()->getId(), LanguageInterface::LANGCODE_NOT_SPECIFIED); $this->assertEqual($item->getGuid(), '395218 at https://groups.drupal.org'); } diff --git a/core/modules/migrate_drupal/lib/Drupal/migrate_drupal/Tests/d6/MigrateCommentTest.php b/core/modules/migrate_drupal/lib/Drupal/migrate_drupal/Tests/d6/MigrateCommentTest.php index 409f6d2..03acbed 100644 --- a/core/modules/migrate_drupal/lib/Drupal/migrate_drupal/Tests/d6/MigrateCommentTest.php +++ b/core/modules/migrate_drupal/lib/Drupal/migrate_drupal/Tests/d6/MigrateCommentTest.php @@ -8,7 +8,7 @@ namespace Drupal\migrate_drupal\Tests\d6; use Drupal\comment\Entity\Comment; -use Drupal\Core\Language\Language; +use Drupal\Core\Language\LanguageInterface; use Drupal\migrate\MigrateExecutable; use Drupal\migrate_drupal\Tests\MigrateDrupalTestBase; @@ -76,7 +76,7 @@ public function testComments() { $this->assertEqual(0, $comment->pid->value); $this->assertEqual(1, $comment->entity_id->value); $this->assertEqual('node', $comment->entity_type->value); - $this->assertEqual(Language::LANGCODE_NOT_SPECIFIED, $comment->language()->id); + $this->assertEqual(LanguageInterface::LANGCODE_NOT_SPECIFIED, $comment->language()->getId()); $comment = entity_load('comment', 2); $this->assertEqual('The response to the second comment.', $comment->subject->value); diff --git a/core/modules/migrate_drupal/lib/Drupal/migrate_drupal/Tests/d6/MigrateCustomBlockTest.php b/core/modules/migrate_drupal/lib/Drupal/migrate_drupal/Tests/d6/MigrateCustomBlockTest.php index d48acaf..49edd03 100644 --- a/core/modules/migrate_drupal/lib/Drupal/migrate_drupal/Tests/d6/MigrateCustomBlockTest.php +++ b/core/modules/migrate_drupal/lib/Drupal/migrate_drupal/Tests/d6/MigrateCustomBlockTest.php @@ -7,7 +7,7 @@ namespace Drupal\migrate_drupal\Tests\d6; -use Drupal\Core\Language\Language; +use Drupal\Core\Language\LanguageInterface; use Drupal\custom_block\Entity\CustomBlock; use Drupal\migrate\MigrateExecutable; use Drupal\migrate_drupal\Tests\MigrateDrupalTestBase; @@ -59,7 +59,7 @@ public function testBlockMigration() { $this->assertEqual('My block 1', $block->label()); $this->assertEqual(1, $block->getRevisionId()); $this->assertTrue(REQUEST_TIME <= $block->getChangedTime() && $block->getChangedTime() <= time()); - $this->assertEqual(Language::LANGCODE_NOT_SPECIFIED, $block->language()->id); + $this->assertEqual(LanguageInterface::LANGCODE_NOT_SPECIFIED, $block->language()->getId()); $this->assertEqual('

My first custom block body

', $block->body->value); $this->assertEqual('full_html', $block->body->format); @@ -67,7 +67,7 @@ public function testBlockMigration() { $this->assertEqual('My block 2', $block->label()); $this->assertEqual(2, $block->getRevisionId()); $this->assertTrue(REQUEST_TIME <= $block->getChangedTime() && $block->getChangedTime() <= time()); - $this->assertEqual(Language::LANGCODE_NOT_SPECIFIED, $block->language()->id); + $this->assertEqual(LanguageInterface::LANGCODE_NOT_SPECIFIED, $block->language()->getId()); $this->assertEqual('

My second custom block body

', $block->body->value); $this->assertEqual('full_html', $block->body->format); } diff --git a/core/modules/node/lib/Drupal/node/Access/NodeRevisionAccessCheck.php b/core/modules/node/lib/Drupal/node/Access/NodeRevisionAccessCheck.php index 66dc7e2..06da782 100644 --- a/core/modules/node/lib/Drupal/node/Access/NodeRevisionAccessCheck.php +++ b/core/modules/node/lib/Drupal/node/Access/NodeRevisionAccessCheck.php @@ -127,7 +127,7 @@ public function checkAccess(NodeInterface $node, AccountInterface $account, $op // If no language code was provided, default to the node revision's langcode. if (empty($langcode)) { - $langcode = $node->language()->id; + $langcode = $node->language()->getId(); } // Statically cache access by revision ID, language code, user account ID, diff --git a/core/modules/node/lib/Drupal/node/Controller/NodeController.php b/core/modules/node/lib/Drupal/node/Controller/NodeController.php index ccc3037..7874ebf 100644 --- a/core/modules/node/lib/Drupal/node/Controller/NodeController.php +++ b/core/modules/node/lib/Drupal/node/Controller/NodeController.php @@ -70,7 +70,7 @@ public function add(NodeTypeInterface $node_type) { 'uid' => $account->id(), 'name' => $account->getUsername() ?: '', 'type' => $node_type->type, - 'langcode' => $langcode ? $langcode : $this->languageManager()->getCurrentLanguage()->id, + 'langcode' => $langcode ? $langcode : $this->languageManager()->getCurrentLanguage()->getId(), )); $form = $this->entityFormBuilder()->getForm($node); diff --git a/core/modules/node/lib/Drupal/node/Entity/Node.php b/core/modules/node/lib/Drupal/node/Entity/Node.php index 1d21504..ede6ed7 100644 --- a/core/modules/node/lib/Drupal/node/Entity/Node.php +++ b/core/modules/node/lib/Drupal/node/Entity/Node.php @@ -11,7 +11,7 @@ use Drupal\Core\Entity\EntityStorageInterface; use Drupal\Core\Entity\EntityTypeInterface; use Drupal\Core\Field\FieldDefinition; -use Drupal\Core\Language\Language; +use Drupal\Core\Language\LanguageInterface; use Drupal\Core\Session\AccountInterface; use Drupal\node\NodeInterface; use Drupal\user\UserInterface; @@ -156,14 +156,14 @@ public function access($operation = 'view', AccountInterface $account = NULL) { * {@inheritdoc} */ public function prepareLangcode() { - $langcode = $this->language()->id; + $langcode = $this->language()->getId(); // If the Language module is enabled, try to use the language from content // negotiation. if (\Drupal::moduleHandler()->moduleExists('language')) { // Load languages the node exists in. $node_translations = $this->getTranslationLanguages(); // Load the language from content negotiation. - $content_negotiation_langcode = \Drupal::languageManager()->getCurrentLanguage(Language::TYPE_CONTENT)->id; + $content_negotiation_langcode = \Drupal::languageManager()->getCurrentLanguage(LanguageInterface::TYPE_CONTENT)->getId(); // If there is a translation available, use it. if (isset($node_translations[$content_negotiation_langcode])) { $langcode = $content_negotiation_langcode; diff --git a/core/modules/node/lib/Drupal/node/NodeAccessController.php b/core/modules/node/lib/Drupal/node/NodeAccessController.php index 7b85600..6c058ad 100644 --- a/core/modules/node/lib/Drupal/node/NodeAccessController.php +++ b/core/modules/node/lib/Drupal/node/NodeAccessController.php @@ -11,7 +11,7 @@ use Drupal\Core\Database\Query\SelectInterface; use Drupal\Core\Entity\EntityControllerInterface; use Drupal\Core\Entity\EntityTypeInterface; -use Drupal\Core\Language\Language; +use Drupal\Core\Language\LanguageInterface; use Drupal\Core\Entity\EntityAccessController; use Drupal\Core\Entity\EntityInterface; use Drupal\Core\Entity\ContentEntityBase; @@ -58,7 +58,7 @@ public static function createInstance(ContainerInterface $container, EntityTypeI /** * {@inheritdoc} */ - public function access(EntityInterface $entity, $operation, $langcode = Language::LANGCODE_DEFAULT, AccountInterface $account = NULL) { + public function access(EntityInterface $entity, $operation, $langcode = LanguageInterface::LANGCODE_DEFAULT, AccountInterface $account = NULL) { if (user_access('bypass node access', $account)) { return TRUE; } diff --git a/core/modules/node/lib/Drupal/node/NodeForm.php b/core/modules/node/lib/Drupal/node/NodeForm.php index 37bb7da..06d0070 100644 --- a/core/modules/node/lib/Drupal/node/NodeForm.php +++ b/core/modules/node/lib/Drupal/node/NodeForm.php @@ -11,7 +11,7 @@ use Drupal\Core\Cache\Cache; use Drupal\Core\Datetime\DrupalDateTime; use Drupal\Core\Entity\ContentEntityForm; -use Drupal\Core\Language\Language; +use Drupal\Core\Language\LanguageInterface; use Drupal\Component\Utility\String; /** @@ -89,8 +89,8 @@ public function form(array $form, array &$form_state) { $form['langcode'] = array( '#title' => t('Language'), '#type' => 'language_select', - '#default_value' => $node->getUntranslated()->language()->id, - '#languages' => Language::STATE_ALL, + '#default_value' => $node->getUntranslated()->language()->getId(), + '#languages' => LanguageInterface::STATE_ALL, '#access' => isset($language_configuration['language_show']) && $language_configuration['language_show'], ); diff --git a/core/modules/node/lib/Drupal/node/NodeGrantDatabaseStorage.php b/core/modules/node/lib/Drupal/node/NodeGrantDatabaseStorage.php index 9503713..8d34418 100644 --- a/core/modules/node/lib/Drupal/node/NodeGrantDatabaseStorage.php +++ b/core/modules/node/lib/Drupal/node/NodeGrantDatabaseStorage.php @@ -190,7 +190,7 @@ public function write(NodeInterface $node, array $grants, $realm = NULL, $delete $grant['nid'] = $node->id(); $grant['langcode'] = $grant_langcode; // The record with the original langcode is used as the fallback. - if ($grant['langcode'] == $node->language()->id) { + if ($grant['langcode'] == $node->language()->getId()) { $grant['fallback'] = 1; } else { diff --git a/core/modules/node/lib/Drupal/node/NodeListBuilder.php b/core/modules/node/lib/Drupal/node/NodeListBuilder.php index fc9c0ba..1c3fafd 100644 --- a/core/modules/node/lib/Drupal/node/NodeListBuilder.php +++ b/core/modules/node/lib/Drupal/node/NodeListBuilder.php @@ -13,7 +13,7 @@ use Drupal\Core\Entity\EntityListBuilder; use Drupal\Core\Entity\EntityStorageInterface; use Drupal\Core\Entity\EntityTypeInterface; -use Drupal\Core\Language\Language; +use Drupal\Core\Language\LanguageInterface; use Symfony\Component\DependencyInjection\ContainerInterface; /** @@ -96,10 +96,10 @@ public function buildRow(EntityInterface $entity) { '#theme' => 'mark', '#mark_type' => node_mark($entity->id(), $entity->getChangedTime()), ); - $langcode = $entity->language()->id; + $langcode = $entity->language()->getId(); $uri = $entity->urlInfo(); $options = $uri->getOptions(); - $options += ($langcode != Language::LANGCODE_NOT_SPECIFIED && isset($languages[$langcode]) ? array('language' => $languages[$langcode]) : array()); + $options += ($langcode != LanguageInterface::LANGCODE_NOT_SPECIFIED && isset($languages[$langcode]) ? array('language' => $languages[$langcode]) : array()); $uri->setOptions($options); $row['title']['data'] = array( '#type' => 'link', diff --git a/core/modules/node/lib/Drupal/node/NodeViewBuilder.php b/core/modules/node/lib/Drupal/node/NodeViewBuilder.php index 494183f..85fc50d 100644 --- a/core/modules/node/lib/Drupal/node/NodeViewBuilder.php +++ b/core/modules/node/lib/Drupal/node/NodeViewBuilder.php @@ -58,7 +58,7 @@ public function buildComponents(array &$build, array $entities, array $displays, $build[$id]['langcode'] = array( '#type' => 'item', '#title' => t('Language'), - '#markup' => $entity->language()->name, + '#markup' => $entity->language()->getName(), '#prefix' => '
', '#suffix' => '
' ); diff --git a/core/modules/node/lib/Drupal/node/Plugin/Search/NodeSearch.php b/core/modules/node/lib/Drupal/node/Plugin/Search/NodeSearch.php index 1bcd79b..bb7255e 100644 --- a/core/modules/node/lib/Drupal/node/Plugin/Search/NodeSearch.php +++ b/core/modules/node/lib/Drupal/node/Plugin/Search/NodeSearch.php @@ -13,7 +13,7 @@ use Drupal\Core\Entity\EntityManagerInterface; use Drupal\Core\Extension\ModuleHandlerInterface; use Drupal\Core\State\StateInterface; -use Drupal\Core\Language\Language; +use Drupal\Core\Language\LanguageInterface; use Drupal\Core\Session\AccountInterface; use Drupal\Core\Access\AccessibleInterface; use Drupal\Core\Database\Query\Condition; @@ -287,7 +287,7 @@ public function execute() { 'extra' => $extra, 'score' => $item->calculated_score, 'snippet' => search_excerpt($keys, $node->rendered, $item->langcode), - 'langcode' => $node->language()->id, + 'langcode' => $node->language()->getId(), ); } return $results; @@ -351,23 +351,23 @@ protected function indexNode(NodeInterface $node) { $node_render = $this->entityManager->getViewBuilder('node'); foreach ($languages as $language) { - $node = $node->getTranslation($language->id); + $node = $node->getTranslation($language->getId()); // Render the node. - $build = $node_render->view($node, 'search_index', $language->id); + $build = $node_render->view($node, 'search_index', $language->getId()); unset($build['#theme']); $node->rendered = drupal_render($build); - $text = '

' . check_plain($node->label($language->id)) . '

' . $node->rendered; + $text = '

' . check_plain($node->label($language->getId())) . '

' . $node->rendered; // Fetch extra data normally not visible. - $extra = $this->moduleHandler->invokeAll('node_update_index', array($node, $language->id)); + $extra = $this->moduleHandler->invokeAll('node_update_index', array($node, $language->getId())); foreach ($extra as $t) { $text .= $t; } // Update index. - search_index($node->id(), $this->getPluginId(), $text, $language->id); + search_index($node->id(), $this->getPluginId(), $text, $language->getId()); } } @@ -452,10 +452,10 @@ public function searchFormAlter(array &$form, array &$form_state) { // Add languages. $language_options = array(); - $language_list = \Drupal::languageManager()->getLanguages(Language::STATE_ALL); + $language_list = \Drupal::languageManager()->getLanguages(LanguageInterface::STATE_ALL); foreach ($language_list as $langcode => $language) { // Make locked languages appear special in the list. - $language_options[$langcode] = $language->locked ? t('- @name -', array('@name' => $language->name)) : $language->name; + $language_options[$langcode] = $language->isLocked() ? t('- @name -', array('@name' => $language->getName())) : $language->getName(); } if (count($language_options) > 1) { $form['advanced']['lang-fieldset'] = array( diff --git a/core/modules/node/lib/Drupal/node/Tests/NodeAccessLanguageTest.php b/core/modules/node/lib/Drupal/node/Tests/NodeAccessLanguageTest.php index feeae45..e90b48b 100644 --- a/core/modules/node/lib/Drupal/node/Tests/NodeAccessLanguageTest.php +++ b/core/modules/node/lib/Drupal/node/Tests/NodeAccessLanguageTest.php @@ -8,6 +8,7 @@ namespace Drupal\node\Tests; use Drupal\Core\Language\Language; +use Drupal\Core\Language\LanguageInterface; /** * Verifies node access functionality for multiple languages. @@ -65,7 +66,7 @@ function testNodeAccess() { // Creating a public node with langcode Hungarian, will be saved as the // fallback in node access table. $node_public_hu = $this->drupalCreateNode(array('body' => array(array()), 'langcode' => 'hu', 'private' => FALSE)); - $this->assertTrue($node_public_hu->language()->id == 'hu', 'Node created as Hungarian.'); + $this->assertTrue($node_public_hu->language()->getId() == 'hu', 'Node created as Hungarian.'); // Tests the default access is provided for the public Hungarian node. $this->assertNodeAccess($expected_node_access, $node_public_hu, $web_user); @@ -82,7 +83,7 @@ function testNodeAccess() { // Creating a public node with no special langcode, like when no language // module enabled. $node_public_no_language = $this->drupalCreateNode(array('private' => FALSE)); - $this->assertTrue($node_public_no_language->language()->id == Language::LANGCODE_NOT_SPECIFIED, 'Node created with not specified language.'); + $this->assertTrue($node_public_no_language->language()->getId() == LanguageInterface::LANGCODE_NOT_SPECIFIED, 'Node created with not specified language.'); // Tests that access is granted if requested with no language. $this->assertNodeAccess($expected_node_access, $node_public_no_language, $web_user); @@ -100,7 +101,7 @@ function testNodeAccess() { \Drupal::entityManager()->getAccessController('node')->resetCache(); \Drupal::state()->set('node_access_test_secret_catalan', 1); $node_public_ca = $this->drupalCreateNode(array('body' => array(array()), 'langcode' => 'ca', 'private' => FALSE)); - $this->assertTrue($node_public_ca->language()->id == 'ca', 'Node created as Catalan.'); + $this->assertTrue($node_public_ca->language()->getId() == 'ca', 'Node created as Catalan.'); // Tests that access is granted if requested with no language. $this->assertNodeAccess($expected_node_access, $node_public_no_language, $web_user); @@ -155,7 +156,7 @@ function testNodeAccessPrivate() { // Creating a private node with langcode Hungarian, will be saved as the // fallback in node access table. $node_private_hu = $this->drupalCreateNode(array('body' => array(array()), 'langcode' => 'hu', 'private' => TRUE)); - $this->assertTrue($node_private_hu->language()->id == 'hu', 'Node created as Hungarian.'); + $this->assertTrue($node_private_hu->language()->getId() == 'hu', 'Node created as Hungarian.'); // Tests the default access is not provided for the private Hungarian node. $this->assertNodeAccess($expected_node_access_no_access, $node_private_hu, $web_user); @@ -172,7 +173,7 @@ function testNodeAccessPrivate() { // Creating a private node with no special langcode, like when no language // module enabled. $node_private_no_language = $this->drupalCreateNode(array('private' => TRUE)); - $this->assertTrue($node_private_no_language->language()->id == Language::LANGCODE_NOT_SPECIFIED, 'Node created with not specified language.'); + $this->assertTrue($node_private_no_language->language()->getId() == LanguageInterface::LANGCODE_NOT_SPECIFIED, 'Node created with not specified language.'); // Tests that access is not granted if requested with no language. $this->assertNodeAccess($expected_node_access_no_access, $node_private_no_language, $web_user); @@ -203,7 +204,7 @@ function testNodeAccessPrivate() { // node_access_test_secret_catalan flag works. $private_ca_user = $this->drupalCreateUser(array('access content', 'node test view')); $node_private_ca = $this->drupalCreateNode(array('body' => array(array()), 'langcode' => 'ca', 'private' => TRUE)); - $this->assertTrue($node_private_ca->language()->id == 'ca', 'Node created as Catalan.'); + $this->assertTrue($node_private_ca->language()->getId() == 'ca', 'Node created as Catalan.'); // Tests that Catalan is still not accessible to either user. $this->assertNodeAccess($expected_node_access_no_access, $node_private_ca, $web_user, 'ca'); @@ -235,17 +236,17 @@ function testNodeAccessQueryTag() { // Creating a private node with langcode Hungarian, will be saved as // the fallback in node access table. $node_private = $this->drupalCreateNode(array('body' => array(array()), 'langcode' => 'hu', 'private' => TRUE)); - $this->assertTrue($node_private->language()->id == 'hu', 'Node created as Hungarian.'); + $this->assertTrue($node_private->language()->getId() == 'hu', 'Node created as Hungarian.'); // Creating a public node with langcode Hungarian, will be saved as // the fallback in node access table. $node_public = $this->drupalCreateNode(array('body' => array(array()), 'langcode' => 'hu', 'private' => FALSE)); - $this->assertTrue($node_public->language()->id == 'hu', 'Node created as Hungarian.'); + $this->assertTrue($node_public->language()->getId() == 'hu', 'Node created as Hungarian.'); // Creating a public node with no special langcode, like when no language // module enabled. $node_no_language = $this->drupalCreateNode(array('private' => FALSE)); - $this->assertTrue($node_no_language->language()->id == Language::LANGCODE_NOT_SPECIFIED, 'Node created with not specified language.'); + $this->assertTrue($node_no_language->language()->getId() == LanguageInterface::LANGCODE_NOT_SPECIFIED, 'Node created with not specified language.'); // Query the nodes table as the web user with the node access tag and no // specific langcode. diff --git a/core/modules/node/lib/Drupal/node/Tests/NodeAccessPagerTest.php b/core/modules/node/lib/Drupal/node/Tests/NodeAccessPagerTest.php index ee9f7cd..75a17c9 100644 --- a/core/modules/node/lib/Drupal/node/Tests/NodeAccessPagerTest.php +++ b/core/modules/node/lib/Drupal/node/Tests/NodeAccessPagerTest.php @@ -7,7 +7,6 @@ namespace Drupal\node\Tests; -use Drupal\Core\Language\Language; use Drupal\comment\CommentInterface; use Drupal\simpletest\WebTestBase; diff --git a/core/modules/node/lib/Drupal/node/Tests/NodeCreationTest.php b/core/modules/node/lib/Drupal/node/Tests/NodeCreationTest.php index 540f952..62846cf 100644 --- a/core/modules/node/lib/Drupal/node/Tests/NodeCreationTest.php +++ b/core/modules/node/lib/Drupal/node/Tests/NodeCreationTest.php @@ -8,7 +8,7 @@ namespace Drupal\node\Tests; use Drupal\Core\Database\Database; -use Drupal\Core\Language\Language; +use Drupal\Core\Language\LanguageInterface; /** * Tests creating and saving a node. @@ -84,7 +84,7 @@ function testFailedPageCreation() { 'uid' => $this->loggedInUser->id(), 'name' => $this->loggedInUser->name, 'type' => 'page', - 'langcode' => Language::LANGCODE_NOT_SPECIFIED, + 'langcode' => LanguageInterface::LANGCODE_NOT_SPECIFIED, 'title' => 'testing_transaction_exception', ); diff --git a/core/modules/node/lib/Drupal/node/Tests/NodeFieldMultilingualTestCase.php b/core/modules/node/lib/Drupal/node/Tests/NodeFieldMultilingualTestCase.php index fd83b93..5ff1160 100644 --- a/core/modules/node/lib/Drupal/node/Tests/NodeFieldMultilingualTestCase.php +++ b/core/modules/node/lib/Drupal/node/Tests/NodeFieldMultilingualTestCase.php @@ -8,6 +8,7 @@ namespace Drupal\node\Tests; use Drupal\field\Entity\FieldConfig; +use Drupal\Core\Language\LanguageInterface; use Drupal\language\Plugin\LanguageNegotiation\LanguageNegotiationUrl; use Drupal\simpletest\WebTestBase; use Drupal\Core\Language\Language; @@ -86,7 +87,7 @@ function testMultilingualNodeForm() { // Check that the node exists in the database. $node = $this->drupalGetNodeByTitle($edit[$title_key]); $this->assertTrue($node, 'Node found in database.'); - $this->assertTrue($node->language()->id == $langcode && $node->body->value == $body_value, 'Field language correctly set.'); + $this->assertTrue($node->language()->getId() == $langcode && $node->body->value == $body_value, 'Field language correctly set.'); // Change node language. $langcode = 'it'; @@ -98,10 +99,10 @@ function testMultilingualNodeForm() { $this->drupalPostForm(NULL, $edit, t('Save')); $node = $this->drupalGetNodeByTitle($edit[$title_key], TRUE); $this->assertTrue($node, 'Node found in database.'); - $this->assertTrue($node->language()->id == $langcode && $node->body->value == $body_value, 'Field language correctly changed.'); + $this->assertTrue($node->language()->getId() == $langcode && $node->body->value == $body_value, 'Field language correctly changed.'); // Enable content language URL detection. - $this->container->get('language_negotiator')->saveConfiguration(Language::TYPE_CONTENT, array(LanguageNegotiationUrl::METHOD_ID => 0)); + $this->container->get('language_negotiator')->saveConfiguration(LanguageInterface::TYPE_CONTENT, array(LanguageNegotiationUrl::METHOD_ID => 0)); // Test multilingual field language fallback logic. $this->drupalGet("it/node/{$node->id()}"); diff --git a/core/modules/node/lib/Drupal/node/Tests/NodeLastChangedTest.php b/core/modules/node/lib/Drupal/node/Tests/NodeLastChangedTest.php index bf23498..6f804a5 100644 --- a/core/modules/node/lib/Drupal/node/Tests/NodeLastChangedTest.php +++ b/core/modules/node/lib/Drupal/node/Tests/NodeLastChangedTest.php @@ -49,7 +49,7 @@ function testNodeLastChanged() { $changed_timestamp = node_last_changed($node->id()); $this->assertEqual($changed_timestamp, $node->getChangedTime(), 'Expected last changed timestamp returned.'); - $changed_timestamp = node_last_changed($node->id(), $node->language()->id); + $changed_timestamp = node_last_changed($node->id(), $node->language()->getId()); $this->assertEqual($changed_timestamp, $node->getChangedTime(), 'Expected last changed timestamp returned.'); } } diff --git a/core/modules/node/lib/Drupal/node/Tests/NodeRevisionsAllTestCase.php b/core/modules/node/lib/Drupal/node/Tests/NodeRevisionsAllTestCase.php index abc6668..6ce4832 100644 --- a/core/modules/node/lib/Drupal/node/Tests/NodeRevisionsAllTestCase.php +++ b/core/modules/node/lib/Drupal/node/Tests/NodeRevisionsAllTestCase.php @@ -7,8 +7,6 @@ namespace Drupal\node\Tests; -use Drupal\Core\Language\Language; - /** * Tests actions against revisions for user with access to all revisions. */ diff --git a/core/modules/node/lib/Drupal/node/Tests/NodeRevisionsTest.php b/core/modules/node/lib/Drupal/node/Tests/NodeRevisionsTest.php index bcb62fc..78db6b9 100644 --- a/core/modules/node/lib/Drupal/node/Tests/NodeRevisionsTest.php +++ b/core/modules/node/lib/Drupal/node/Tests/NodeRevisionsTest.php @@ -7,8 +7,6 @@ namespace Drupal\node\Tests; -use Drupal\Core\Language\Language; - /** * Tests the node revision functionality. */ diff --git a/core/modules/node/lib/Drupal/node/Tests/NodeTokenReplaceTest.php b/core/modules/node/lib/Drupal/node/Tests/NodeTokenReplaceTest.php index 717abcc..17a482d 100644 --- a/core/modules/node/lib/Drupal/node/Tests/NodeTokenReplaceTest.php +++ b/core/modules/node/lib/Drupal/node/Tests/NodeTokenReplaceTest.php @@ -76,14 +76,14 @@ function testNodeTokenReplacement() { $tests['[node:title]'] = check_plain($node->getTitle()); $tests['[node:body]'] = $node->body->processed; $tests['[node:summary]'] = $node->body->summary_processed; - $tests['[node:langcode]'] = check_plain($node->language()->id); + $tests['[node:langcode]'] = check_plain($node->language()->getId()); $tests['[node:url]'] = url('node/' . $node->id(), $url_options); $tests['[node:edit-url]'] = url('node/' . $node->id() . '/edit', $url_options); $tests['[node:author]'] = String::checkPlain($account->getUsername()); $tests['[node:author:uid]'] = $node->getOwnerId(); $tests['[node:author:name]'] = String::checkPlain($account->getUsername()); - $tests['[node:created:since]'] = \Drupal::service('date')->formatInterval(REQUEST_TIME - $node->getCreatedTime(), 2, $this->languageInterface->id); - $tests['[node:changed:since]'] = \Drupal::service('date')->formatInterval(REQUEST_TIME - $node->getChangedTime(), 2, $this->languageInterface->id); + $tests['[node:created:since]'] = \Drupal::service('date')->formatInterval(REQUEST_TIME - $node->getCreatedTime(), 2, $this->languageInterface->getId()); + $tests['[node:changed:since]'] = \Drupal::service('date')->formatInterval(REQUEST_TIME - $node->getChangedTime(), 2, $this->languageInterface->getId()); // Test to make sure that we generated something for each token. $this->assertFalse(in_array(0, array_map('strlen', $tests)), 'No empty tokens generated.'); @@ -97,7 +97,7 @@ function testNodeTokenReplacement() { $tests['[node:title]'] = $node->getTitle(); $tests['[node:body]'] = $node->body->value; $tests['[node:summary]'] = $node->body->summary; - $tests['[node:langcode]'] = $node->language()->id; + $tests['[node:langcode]'] = $node->language()->getId(); $tests['[node:author:name]'] = $account->getUsername(); foreach ($tests as $input => $expected) { diff --git a/core/modules/node/lib/Drupal/node/Tests/PagePreviewTest.php b/core/modules/node/lib/Drupal/node/Tests/PagePreviewTest.php index 48a8ea6..5137bbd 100644 --- a/core/modules/node/lib/Drupal/node/Tests/PagePreviewTest.php +++ b/core/modules/node/lib/Drupal/node/Tests/PagePreviewTest.php @@ -7,7 +7,7 @@ namespace Drupal\node\Tests; -use Drupal\Core\Language\Language; +use Drupal\Core\Language\LanguageInterface; /** * Tests the node entity preview functionality. @@ -47,7 +47,7 @@ function setUp() { 'name' => $this->randomName(), 'description' => $this->randomName(), 'vid' => $this->randomName(), - 'langcode' => Language::LANGCODE_NOT_SPECIFIED, + 'langcode' => LanguageInterface::LANGCODE_NOT_SPECIFIED, 'help' => '', )); $vocabulary->save(); @@ -59,7 +59,7 @@ function setUp() { 'name' => $this->randomName(), 'description' => $this->randomName(), 'vid' => $this->vocabulary->id(), - 'langcode' => Language::LANGCODE_NOT_SPECIFIED, + 'langcode' => LanguageInterface::LANGCODE_NOT_SPECIFIED, )); $term->save(); diff --git a/core/modules/node/lib/Drupal/node/Tests/Views/RowPluginTest.php b/core/modules/node/lib/Drupal/node/Tests/Views/RowPluginTest.php index a44a369..7d83d3a 100644 --- a/core/modules/node/lib/Drupal/node/Tests/Views/RowPluginTest.php +++ b/core/modules/node/lib/Drupal/node/Tests/Views/RowPluginTest.php @@ -7,7 +7,6 @@ namespace Drupal\node\Tests\Views; -use Drupal\Core\Language\Language; use Drupal\views\Views; /** diff --git a/core/modules/node/node.admin.inc b/core/modules/node/node.admin.inc index b0a806d..2da5e05 100644 --- a/core/modules/node/node.admin.inc +++ b/core/modules/node/node.admin.inc @@ -5,7 +5,6 @@ * Content administration and module settings user interface. */ -use Drupal\Core\Language\Language; use Drupal\node\NodeInterface; /** diff --git a/core/modules/node/node.install b/core/modules/node/node.install index b075d93..3fe7dc0 100644 --- a/core/modules/node/node.install +++ b/core/modules/node/node.install @@ -6,7 +6,6 @@ */ use Drupal\Component\Uuid\Uuid; -use Drupal\Core\Language\Language; /** * Implements hook_requirements(). diff --git a/core/modules/node/node.module b/core/modules/node/node.module index 71a1f38..8edb6d6 100644 --- a/core/modules/node/node.module +++ b/core/modules/node/node.module @@ -9,7 +9,6 @@ */ use Drupal\Component\Utility\Xss; -use Drupal\Core\Language\Language; use Drupal\Core\Render\Element; use Drupal\Core\Url; use Symfony\Component\HttpFoundation\Request; @@ -1009,7 +1008,7 @@ function node_block_access(Block $block, $operation, AccountInterface $account, */ function node_feed($nids = FALSE, $channel = array()) { global $base_url; - $language_content = \Drupal::languageManager()->getCurrentLanguage(Language::TYPE_CONTENT); + $language_content = \Drupal::languageManager()->getCurrentLanguage(\Drupal\Core\Language\LanguageInterface::TYPE_CONTENT); $rss_config = \Drupal::config('system.rss'); if ($nids === FALSE) { @@ -1063,7 +1062,7 @@ function node_feed($nids = FALSE, $channel = array()) { 'title' => \Drupal::config('system.site')->get('name'), 'link' => $base_url, 'description' => $rss_config->get('channel.description'), - 'language' => $language_content->id + 'language' => $language_content->getId() ); $channel_extras = array_diff_key($channel, $channel_defaults); $channel = array_merge($channel_defaults, $channel); diff --git a/core/modules/node/node.tokens.inc b/core/modules/node/node.tokens.inc index 8789047..5b3c8a2 100644 --- a/core/modules/node/node.tokens.inc +++ b/core/modules/node/node.tokens.inc @@ -5,7 +5,7 @@ * Builds placeholder replacement tokens for node-related data. */ -use Drupal\Core\Language\Language; +use Drupal\Core\Language\LanguageInterface; /** * Implements hook_token_info(). @@ -94,7 +94,7 @@ function node_tokens($type, $tokens, array $data = array(), array $options = arr $langcode = $options['langcode']; } else { - $langcode = Language::LANGCODE_DEFAULT; + $langcode = LanguageInterface::LANGCODE_DEFAULT; } $sanitize = !empty($options['sanitize']); @@ -164,7 +164,7 @@ function node_tokens($type, $tokens, array $data = array(), array $options = arr break; case 'langcode': - $replacements[$original] = $sanitize ? check_plain($node->language()->id) : $node->language()->id; + $replacements[$original] = $sanitize ? check_plain($node->language()->getId()) : $node->language()->getId(); break; case 'url': diff --git a/core/modules/path/lib/Drupal/path/Form/AddForm.php b/core/modules/path/lib/Drupal/path/Form/AddForm.php index a5b056b..aab238b 100644 --- a/core/modules/path/lib/Drupal/path/Form/AddForm.php +++ b/core/modules/path/lib/Drupal/path/Form/AddForm.php @@ -7,7 +7,7 @@ namespace Drupal\path\Form; -use Drupal\Core\Language\Language; +use Drupal\Core\Language\LanguageInterface; /** * Provides the path add form. @@ -28,7 +28,7 @@ protected function buildPath($pid) { return array( 'source' => '', 'alias' => '', - 'langcode' => Language::LANGCODE_NOT_SPECIFIED, + 'langcode' => LanguageInterface::LANGCODE_NOT_SPECIFIED, 'pid' => NULL, ); } diff --git a/core/modules/path/lib/Drupal/path/Form/PathFormBase.php b/core/modules/path/lib/Drupal/path/Form/PathFormBase.php index ca507d1..75f7cc4 100644 --- a/core/modules/path/lib/Drupal/path/Form/PathFormBase.php +++ b/core/modules/path/lib/Drupal/path/Form/PathFormBase.php @@ -8,7 +8,7 @@ namespace Drupal\path\Form; use Drupal\Core\Form\FormBase; -use Drupal\Core\Language\Language; +use Drupal\Core\Language\LanguageInterface; use Drupal\Core\Path\AliasManagerInterface; use Drupal\Core\Path\AliasStorageInterface; use Drupal\Core\Url; @@ -102,14 +102,14 @@ public function buildForm(array $form, array &$form_state, $pid = NULL) { $languages = \Drupal::languageManager()->getLanguages(); $language_options = array(); foreach ($languages as $langcode => $language) { - $language_options[$langcode] = $language->name; + $language_options[$langcode] = $language->getName(); } $form['langcode'] = array( '#type' => 'select', '#title' => $this->t('Language'), '#options' => $language_options, - '#empty_value' => Language::LANGCODE_NOT_SPECIFIED, + '#empty_value' => LanguageInterface::LANGCODE_NOT_SPECIFIED, '#empty_option' => $this->t('- None -'), '#default_value' => $this->path['langcode'], '#weight' => -10, @@ -141,7 +141,7 @@ public function validateForm(array &$form, array &$form_state) { $alias = $form_state['values']['alias']; // Language is only set if language.module is enabled, otherwise save for all // languages. - $langcode = isset($form_state['values']['langcode']) ? $form_state['values']['langcode'] : Language::LANGCODE_NOT_SPECIFIED; + $langcode = isset($form_state['values']['langcode']) ? $form_state['values']['langcode'] : LanguageInterface::LANGCODE_NOT_SPECIFIED; if ($this->aliasStorage->aliasExists($alias, $langcode, $source)) { $this->setFormError('alias', $form_state, t('The alias %alias is already in use in this language.', array('%alias' => $alias))); @@ -164,7 +164,7 @@ public function submitForm(array &$form, array &$form_state) { $alias = $form_state['values']['alias']; // Language is only set if language.module is enabled, otherwise save for all // languages. - $langcode = isset($form_state['values']['langcode']) ? $form_state['values']['langcode'] : Language::LANGCODE_NOT_SPECIFIED; + $langcode = isset($form_state['values']['langcode']) ? $form_state['values']['langcode'] : LanguageInterface::LANGCODE_NOT_SPECIFIED; $this->aliasStorage->save($source, $alias, $langcode, $pid); diff --git a/core/modules/path/lib/Drupal/path/Plugin/Field/FieldWidget/PathWidget.php b/core/modules/path/lib/Drupal/path/Plugin/Field/FieldWidget/PathWidget.php index ac465d9..e416bc5 100644 --- a/core/modules/path/lib/Drupal/path/Plugin/Field/FieldWidget/PathWidget.php +++ b/core/modules/path/lib/Drupal/path/Plugin/Field/FieldWidget/PathWidget.php @@ -9,7 +9,7 @@ use Drupal\Core\Field\FieldItemListInterface; use Drupal\Core\Field\WidgetBase; -use Drupal\Core\Language\Language; +use Drupal\Core\Language\LanguageInterface; use Symfony\Component\Validator\ConstraintViolationInterface; /** @@ -33,7 +33,7 @@ public function formElement(FieldItemListInterface $items, $delta, array $elemen $path = array(); if (!$entity->isNew()) { $conditions = array('source' => $entity->getSystemPath()); - if ($items->getLangcode() != Language::LANGCODE_NOT_SPECIFIED) { + if ($items->getLangcode() != LanguageInterface::LANGCODE_NOT_SPECIFIED) { $conditions['langcode'] = $items->getLangcode(); } $path = \Drupal::service('path.alias_storage')->load($conditions); diff --git a/core/modules/path/path.module b/core/modules/path/path.module index ab102a9..2378423 100644 --- a/core/modules/path/path.module +++ b/core/modules/path/path.module @@ -6,7 +6,6 @@ */ use Drupal\Core\Entity\EntityTypeInterface; -use Drupal\Core\Language\Language; use Drupal\Core\Entity\EntityInterface; use Drupal\Core\Entity\ContentEntityInterface; use Drupal\Core\Field\FieldDefinition; diff --git a/core/modules/quickedit/lib/Drupal/quickedit/Tests/EditorSelectionTest.php b/core/modules/quickedit/lib/Drupal/quickedit/Tests/EditorSelectionTest.php index b84f3af..03ce968 100644 --- a/core/modules/quickedit/lib/Drupal/quickedit/Tests/EditorSelectionTest.php +++ b/core/modules/quickedit/lib/Drupal/quickedit/Tests/EditorSelectionTest.php @@ -7,7 +7,7 @@ namespace Drupal\quickedit\Tests; -use Drupal\Core\Language\Language; +use Drupal\Core\Language\LanguageInterface; use Drupal\quickedit\Plugin\InPlaceEditorManager; use Drupal\quickedit\EditorSelector; @@ -50,7 +50,7 @@ protected function setUp() { */ protected function getSelectedEditor($entity_id, $field_name, $view_mode = 'default') { $entity = entity_load('entity_test', $entity_id, TRUE); - $items = $entity->getTranslation(Language::LANGCODE_NOT_SPECIFIED)->get($field_name); + $items = $entity->getTranslation(LanguageInterface::LANGCODE_NOT_SPECIFIED)->get($field_name); $options = entity_get_display('entity_test', 'entity_test', $view_mode)->getComponent($field_name); return $this->editorSelector->getEditor($options['type'], $items); } diff --git a/core/modules/quickedit/lib/Drupal/quickedit/Tests/MetadataGeneratorTest.php b/core/modules/quickedit/lib/Drupal/quickedit/Tests/MetadataGeneratorTest.php index 3a07223..7418ec0 100644 --- a/core/modules/quickedit/lib/Drupal/quickedit/Tests/MetadataGeneratorTest.php +++ b/core/modules/quickedit/lib/Drupal/quickedit/Tests/MetadataGeneratorTest.php @@ -7,7 +7,7 @@ namespace Drupal\quickedit\Tests; -use Drupal\Core\Language\Language; +use Drupal\Core\Language\LanguageInterface; use Drupal\quickedit\EditorSelector; use Drupal\quickedit\MetadataGenerator; use Drupal\quickedit\Plugin\InPlaceEditorManager; @@ -102,7 +102,7 @@ public function testSimpleEntityType() { $entity = entity_load('entity_test', $this->entity->id()); // Verify metadata for field 1. - $items_1 = $entity->getTranslation(Language::LANGCODE_NOT_SPECIFIED)->get($field_1_name); + $items_1 = $entity->getTranslation(LanguageInterface::LANGCODE_NOT_SPECIFIED)->get($field_1_name); $metadata_1 = $this->metadataGenerator->generateFieldMetadata($items_1, 'default'); $expected_1 = array( 'access' => TRUE, @@ -113,7 +113,7 @@ public function testSimpleEntityType() { $this->assertEqual($expected_1, $metadata_1, 'The correct metadata is generated for the first field.'); // Verify metadata for field 2. - $items_2 = $entity->getTranslation(Language::LANGCODE_NOT_SPECIFIED)->get($field_2_name); + $items_2 = $entity->getTranslation(LanguageInterface::LANGCODE_NOT_SPECIFIED)->get($field_2_name); $metadata_2 = $this->metadataGenerator->generateFieldMetadata($items_2, 'default'); $expected_2 = array( 'access' => TRUE, @@ -175,7 +175,7 @@ public function testEditorWithCustomMetadata() { $entity = entity_load('entity_test', $this->entity->id()); // Verify metadata. - $items = $entity->getTranslation(Language::LANGCODE_NOT_SPECIFIED)->get($field_name); + $items = $entity->getTranslation(LanguageInterface::LANGCODE_NOT_SPECIFIED)->get($field_name); $metadata = $this->metadataGenerator->generateFieldMetadata($items, 'default'); $expected = array( 'access' => TRUE, diff --git a/core/modules/quickedit/lib/Drupal/quickedit/Tests/QuickEditAutocompleteTermTest.php b/core/modules/quickedit/lib/Drupal/quickedit/Tests/QuickEditAutocompleteTermTest.php index 15d8ca9..9bee3e1 100644 --- a/core/modules/quickedit/lib/Drupal/quickedit/Tests/QuickEditAutocompleteTermTest.php +++ b/core/modules/quickedit/lib/Drupal/quickedit/Tests/QuickEditAutocompleteTermTest.php @@ -9,7 +9,7 @@ use Drupal\Component\Serialization\Json; use Drupal\Core\Field\FieldDefinitionInterface; -use Drupal\Core\Language\Language; +use Drupal\Core\Language\LanguageInterface; use Drupal\simpletest\WebTestBase; /** @@ -211,7 +211,7 @@ protected function createTerm() { // Use the first available text format. 'format' => $format->format, 'vid' => $this->vocabulary->id(), - 'langcode' => Language::LANGCODE_NOT_SPECIFIED, + 'langcode' => LanguageInterface::LANGCODE_NOT_SPECIFIED, )); $term->save(); return $term; diff --git a/core/modules/quickedit/tests/Drupal/quickedit/Tests/Access/EditEntityFieldAccessCheckTest.php b/core/modules/quickedit/tests/Drupal/quickedit/Tests/Access/EditEntityFieldAccessCheckTest.php index d1b0228..9b01048 100644 --- a/core/modules/quickedit/tests/Drupal/quickedit/Tests/Access/EditEntityFieldAccessCheckTest.php +++ b/core/modules/quickedit/tests/Drupal/quickedit/Tests/Access/EditEntityFieldAccessCheckTest.php @@ -12,7 +12,7 @@ use Drupal\quickedit\Access\EditEntityFieldAccessCheck; use Drupal\Tests\UnitTestCase; use Drupal\field\FieldConfigInterface; -use Drupal\Core\Language\Language; +use Drupal\Core\Language\LanguageInterface; use Drupal\Core\Entity\EntityInterface; /** @@ -127,14 +127,14 @@ public function testAccess(EntityInterface $entity, FieldConfigInterface $field ->will($this->returnValue($field)); $entity_with_field->expects($this->once()) ->method('hasTranslation') - ->with(Language::LANGCODE_NOT_SPECIFIED) + ->with(LanguageInterface::LANGCODE_NOT_SPECIFIED) ->will($this->returnValue(TRUE)); // Prepare the request to be valid. $request->attributes->set('entity_type', 'test_entity'); $request->attributes->set('entity', $entity_with_field); $request->attributes->set('field_name', $field_name); - $request->attributes->set('langcode', Language::LANGCODE_NOT_SPECIFIED); + $request->attributes->set('langcode', LanguageInterface::LANGCODE_NOT_SPECIFIED); $account = $this->getMock('Drupal\Core\Session\AccountInterface'); $access = $this->editAccessCheck->access($request, $field_name, $account); diff --git a/core/modules/quickedit/tests/modules/quickedit_test.module b/core/modules/quickedit/tests/modules/quickedit_test.module index 4d4606c..0a73b25 100644 --- a/core/modules/quickedit/tests/modules/quickedit_test.module +++ b/core/modules/quickedit/tests/modules/quickedit_test.module @@ -5,7 +5,7 @@ * Helper module for the Quick Edit tests. */ -use Drupal\Core\Language\Language; +use Drupal\Core\Language\LanguageInterface; use Drupal\Core\Entity\EntityInterface; use Drupal\Core\Entity\Display\EntityViewDisplayInterface; @@ -21,7 +21,7 @@ function quickedit_test_entity_view_alter(&$build, EntityInterface $entity, Enti '#label_display' => 'Label', '#entity_type' => $entity->getEntityTypeId(), '#bundle' => $entity->bundle(), - '#language' => Language::LANGCODE_NOT_SPECIFIED, + '#language' => LanguageInterface::LANGCODE_NOT_SPECIFIED, '#field_type' => 'pseudo', '#view_mode' => 'default', '#object' => $entity, diff --git a/core/modules/rdf/lib/Drupal/rdf/Tests/Field/TaxonomyTermReferenceRdfaTest.php b/core/modules/rdf/lib/Drupal/rdf/Tests/Field/TaxonomyTermReferenceRdfaTest.php index 5086bf1..e9a74a0 100644 --- a/core/modules/rdf/lib/Drupal/rdf/Tests/Field/TaxonomyTermReferenceRdfaTest.php +++ b/core/modules/rdf/lib/Drupal/rdf/Tests/Field/TaxonomyTermReferenceRdfaTest.php @@ -8,7 +8,7 @@ use Drupal\rdf\Tests\Field\FieldRdfaTestBase; use Drupal\Core\Field\FieldDefinitionInterface; -use Drupal\Core\Language\Language; +use Drupal\Core\Language\LanguageInterface; /** * Tests the RDFa output of the taxonomy term reference field formatter. @@ -55,7 +55,7 @@ public function setUp() { $vocabulary = entity_create('taxonomy_vocabulary', array( 'name' => $this->randomName(), 'vid' => drupal_strtolower($this->randomName()), - 'langcode' => Language::LANGCODE_NOT_SPECIFIED, + 'langcode' => LanguageInterface::LANGCODE_NOT_SPECIFIED, )); $vocabulary->save(); @@ -82,7 +82,7 @@ public function setUp() { $this->term = entity_create('taxonomy_term', array( 'name' => $this->randomName(), 'vid' => $vocabulary->id(), - 'langcode' => Language::LANGCODE_NOT_SPECIFIED, + 'langcode' => LanguageInterface::LANGCODE_NOT_SPECIFIED, )); $this->term->save(); diff --git a/core/modules/rdf/lib/Drupal/rdf/Tests/FileFieldAttributesTest.php b/core/modules/rdf/lib/Drupal/rdf/Tests/FileFieldAttributesTest.php index cc738e4..2381395 100644 --- a/core/modules/rdf/lib/Drupal/rdf/Tests/FileFieldAttributesTest.php +++ b/core/modules/rdf/lib/Drupal/rdf/Tests/FileFieldAttributesTest.php @@ -7,7 +7,6 @@ namespace Drupal\rdf\Tests; -use Drupal\Core\Language\Language; use Drupal\file\Tests\FileFieldTestBase; /** diff --git a/core/modules/rdf/lib/Drupal/rdf/Tests/ImageFieldAttributesTest.php b/core/modules/rdf/lib/Drupal/rdf/Tests/ImageFieldAttributesTest.php index 14af8f6..39e52b7 100644 --- a/core/modules/rdf/lib/Drupal/rdf/Tests/ImageFieldAttributesTest.php +++ b/core/modules/rdf/lib/Drupal/rdf/Tests/ImageFieldAttributesTest.php @@ -7,7 +7,6 @@ namespace Drupal\rdf\Tests; -use Drupal\Core\Language\Language; use Drupal\image\Tests\ImageFieldTestBase; /** diff --git a/core/modules/responsive_image/lib/Drupal/responsive_image/Tests/ResponsiveImageFieldDisplayTest.php b/core/modules/responsive_image/lib/Drupal/responsive_image/Tests/ResponsiveImageFieldDisplayTest.php index 5d34845..fd68a994 100644 --- a/core/modules/responsive_image/lib/Drupal/responsive_image/Tests/ResponsiveImageFieldDisplayTest.php +++ b/core/modules/responsive_image/lib/Drupal/responsive_image/Tests/ResponsiveImageFieldDisplayTest.php @@ -7,7 +7,6 @@ namespace Drupal\responsive_image\Tests; -use Drupal\Core\Language\Language; use Drupal\breakpoint\Entity\Breakpoint; use Drupal\image\Tests\ImageFieldTestBase; diff --git a/core/modules/rest/lib/Drupal/rest/Tests/ReadTest.php b/core/modules/rest/lib/Drupal/rest/Tests/ReadTest.php index 15206f7..6777cf5 100644 --- a/core/modules/rest/lib/Drupal/rest/Tests/ReadTest.php +++ b/core/modules/rest/lib/Drupal/rest/Tests/ReadTest.php @@ -8,7 +8,6 @@ namespace Drupal\rest\Tests; use Drupal\Component\Serialization\Json; -use Drupal\Core\Language\Language; use Drupal\rest\Tests\RESTTestBase; /** diff --git a/core/modules/search/lib/Drupal/search/Tests/SearchMatchTest.php b/core/modules/search/lib/Drupal/search/Tests/SearchMatchTest.php index 27b427d..14ea024 100644 --- a/core/modules/search/lib/Drupal/search/Tests/SearchMatchTest.php +++ b/core/modules/search/lib/Drupal/search/Tests/SearchMatchTest.php @@ -7,7 +7,7 @@ namespace Drupal\search\Tests; -use Drupal\Core\Language\Language; +use Drupal\Core\Language\LanguageInterface; // The search index can contain different types of content. Typically the type // is 'node'. Here we test with _test_ and _test2_ as the type. @@ -42,10 +42,10 @@ function _setup() { \Drupal::config('search.settings')->set('index.minimum_word_size', 3)->save(); for ($i = 1; $i <= 7; ++$i) { - search_index($i, SEARCH_TYPE, $this->getText($i), Language::LANGCODE_NOT_SPECIFIED); + search_index($i, SEARCH_TYPE, $this->getText($i), LanguageInterface::LANGCODE_NOT_SPECIFIED); } for ($i = 1; $i <= 5; ++$i) { - search_index($i + 7, SEARCH_TYPE_2, $this->getText2($i), Language::LANGCODE_NOT_SPECIFIED); + search_index($i + 7, SEARCH_TYPE_2, $this->getText2($i), LanguageInterface::LANGCODE_NOT_SPECIFIED); } // No getText builder function for Japanese text; just a simple array. foreach (array( @@ -53,7 +53,7 @@ function _setup() { 14 => 'ドルーパルが大好きよ!', 15 => 'コーヒーとケーキ', ) as $i => $jpn) { - search_index($i, SEARCH_TYPE_JPN, $jpn, Language::LANGCODE_NOT_SPECIFIED); + search_index($i, SEARCH_TYPE_JPN, $jpn, LanguageInterface::LANGCODE_NOT_SPECIFIED); } search_update_totals(); } diff --git a/core/modules/search/lib/Drupal/search/Tests/SearchNumberMatchingTest.php b/core/modules/search/lib/Drupal/search/Tests/SearchNumberMatchingTest.php index f52a222..65d2bfd 100644 --- a/core/modules/search/lib/Drupal/search/Tests/SearchNumberMatchingTest.php +++ b/core/modules/search/lib/Drupal/search/Tests/SearchNumberMatchingTest.php @@ -7,7 +7,7 @@ namespace Drupal\search\Tests; -use Drupal\Core\Language\Language; +use Drupal\Core\Language\LanguageInterface; /** * Tests that various number formats match each other in searching. @@ -49,7 +49,7 @@ function setUp() { $info = array( 'body' => array(array('value' => $num)), 'type' => 'page', - 'language' => Language::LANGCODE_NOT_SPECIFIED, + 'language' => LanguageInterface::LANGCODE_NOT_SPECIFIED, ); $this->nodes[] = $this->drupalCreateNode($info); } diff --git a/core/modules/search/lib/Drupal/search/Tests/SearchNumbersTest.php b/core/modules/search/lib/Drupal/search/Tests/SearchNumbersTest.php index 6275943..41a41ae 100644 --- a/core/modules/search/lib/Drupal/search/Tests/SearchNumbersTest.php +++ b/core/modules/search/lib/Drupal/search/Tests/SearchNumbersTest.php @@ -7,7 +7,7 @@ namespace Drupal\search\Tests; -use Drupal\Core\Language\Language; +use Drupal\Core\Language\LanguageInterface; /** * Tests that numbers with different formats can be searched. @@ -55,7 +55,7 @@ function setUp() { $info = array( 'body' => array(array('value' => $num)), 'type' => 'page', - 'language' => Language::LANGCODE_NOT_SPECIFIED, + 'language' => LanguageInterface::LANGCODE_NOT_SPECIFIED, 'title' => $doc . ' number', ); $this->nodes[$doc] = $this->drupalCreateNode($info); diff --git a/core/modules/search/search.pages.inc b/core/modules/search/search.pages.inc index 34b235c..bc7ba1b 100644 --- a/core/modules/search/search.pages.inc +++ b/core/modules/search/search.pages.inc @@ -5,8 +5,6 @@ * User page callbacks for the Search module. */ -use Drupal\Core\Language\Language; - /** * Implements hook_theme_suggestions_HOOK(). */ @@ -36,7 +34,7 @@ function template_preprocess_search_result(&$variables) { $result = $variables['result']; $variables['url'] = check_url($result['link']); $variables['title'] = check_plain($result['title']); - if (isset($result['language']) && $result['language'] != $language_interface->id && $result['language'] != Language::LANGCODE_NOT_SPECIFIED) { + if (isset($result['language']) && $result['language'] != $language_interface->getId() && $result['language'] != LanguageInterface::LANGCODE_NOT_SPECIFIED) { $variables['title_attributes']['lang'] = $result['language']; $variables['content_attributes']['lang'] = $result['language']; } diff --git a/core/modules/serialization/lib/Drupal/serialization/Tests/EntitySerializationTest.php b/core/modules/serialization/lib/Drupal/serialization/Tests/EntitySerializationTest.php index 865704d..d53502a 100644 --- a/core/modules/serialization/lib/Drupal/serialization/Tests/EntitySerializationTest.php +++ b/core/modules/serialization/lib/Drupal/serialization/Tests/EntitySerializationTest.php @@ -7,7 +7,7 @@ namespace Drupal\serialization\Tests; -use Drupal\Core\Language\Language; +use Drupal\Core\Language\LanguageInterface; use Symfony\Component\Serializer\Serializer; use Drupal\Component\Utility\String; @@ -87,7 +87,7 @@ public function testNormalize() { array('value' => $this->entity->uuid()), ), 'langcode' => array( - array('value' => Language::LANGCODE_NOT_SPECIFIED), + array('value' => LanguageInterface::LANGCODE_NOT_SPECIFIED), ), 'default_langcode' => array( array('value' => NULL), @@ -143,7 +143,7 @@ public function testSerialize() { 'id' => '' . $this->entity->id() . '', 'revision_id' => '' . $this->entity->getRevisionId() . '', 'uuid' => '' . $this->entity->uuid() . '', - 'langcode' => '' . Language::LANGCODE_NOT_SPECIFIED . '', + 'langcode' => '' . LanguageInterface::LANGCODE_NOT_SPECIFIED . '', 'default_langcode' => '', 'name' => '' . $this->values['name'] . '', 'type' => 'entity_test_mulrev', diff --git a/core/modules/shortcut/shortcut.install b/core/modules/shortcut/shortcut.install index b7ed49c..8b87123 100644 --- a/core/modules/shortcut/shortcut.install +++ b/core/modules/shortcut/shortcut.install @@ -6,7 +6,6 @@ */ use Drupal\Core\Database\Database; -use Drupal\Core\Language\Language; /** * Implements hook_schema(). diff --git a/core/modules/shortcut/src/ShortcutForm.php b/core/modules/shortcut/src/ShortcutForm.php index 0e101ff..89606d1 100644 --- a/core/modules/shortcut/src/ShortcutForm.php +++ b/core/modules/shortcut/src/ShortcutForm.php @@ -8,7 +8,7 @@ namespace Drupal\shortcut; use Drupal\Core\Entity\ContentEntityForm; -use Drupal\Core\Language\Language; +use Drupal\Core\Language\LanguageInterface; /** * Form controller for the shortcut entity forms. @@ -40,8 +40,8 @@ public function form(array $form, array &$form_state) { $form['langcode'] = array( '#title' => t('Language'), '#type' => 'language_select', - '#default_value' => $this->entity->getUntranslated()->language()->id, - '#languages' => Language::STATE_ALL, + '#default_value' => $this->entity->getUntranslated()->language()->getId(), + '#languages' => LanguageInterface::STATE_ALL, ); return $form; diff --git a/core/modules/simpletest/lib/Drupal/simpletest/WebTestBase.php b/core/modules/simpletest/lib/Drupal/simpletest/WebTestBase.php index 340b555..2518cda 100644 --- a/core/modules/simpletest/lib/Drupal/simpletest/WebTestBase.php +++ b/core/modules/simpletest/lib/Drupal/simpletest/WebTestBase.php @@ -16,7 +16,7 @@ use Drupal\Core\Database\Database; use Drupal\Core\Database\ConnectionNotDefinedException; use Drupal\Core\Entity\EntityInterface; -use Drupal\Core\Language\Language; +use Drupal\Core\Language\LanguageInterface; use Drupal\Core\Session\AccountInterface; use Drupal\Core\Session\AnonymousUserSession; use Drupal\Core\Session\UserSession; @@ -251,7 +251,7 @@ function drupalGetNodeByTitle($title, $reset = FALSE) { * - status: NODE_PUBLISHED. * - sticky: NODE_NOT_STICKY. * - type: 'page'. - * - langcode: Language::LANGCODE_NOT_SPECIFIED. + * - langcode: LanguageInterface::LANGCODE_NOT_SPECIFIED. * - uid: The currently logged in user, or the user running test. * - revision: 1. (Backwards-compatible binary flag indicating whether a * new revision should be created; use 1 to specify a new revision.) @@ -270,7 +270,7 @@ protected function drupalCreateNode(array $settings = array()) { 'status' => NODE_PUBLISHED, 'sticky' => NODE_NOT_STICKY, 'type' => 'page', - 'langcode' => Language::LANGCODE_NOT_SPECIFIED, + 'langcode' => LanguageInterface::LANGCODE_NOT_SPECIFIED, ); // Use the original node's created time for existing nodes. diff --git a/core/modules/statistics/lib/Drupal/statistics/Tests/StatisticsTokenReplaceTest.php b/core/modules/statistics/lib/Drupal/statistics/Tests/StatisticsTokenReplaceTest.php index 16c1fda..33910ab 100644 --- a/core/modules/statistics/lib/Drupal/statistics/Tests/StatisticsTokenReplaceTest.php +++ b/core/modules/statistics/lib/Drupal/statistics/Tests/StatisticsTokenReplaceTest.php @@ -7,7 +7,6 @@ namespace Drupal\statistics\Tests; -use Drupal\Core\Language\Language; /** * Tests statistics token replacement in strings. @@ -56,7 +55,7 @@ function testStatisticsTokenReplacement() { $this->assertFalse(in_array(0, array_map('strlen', $tests)), 'No empty tokens generated.'); foreach ($tests as $input => $expected) { - $output = \Drupal::token()->replace($input, array('node' => $node), array('langcode' => $language_interface->id)); + $output = \Drupal::token()->replace($input, array('node' => $node), array('langcode' => $language_interface->getId())); $this->assertEqual($output, $expected, format_string('Statistics token %token replaced.', array('%token' => $input))); } } diff --git a/core/modules/system/core.api.php b/core/modules/system/core.api.php index f2cc90e..7060ca6 100644 --- a/core/modules/system/core.api.php +++ b/core/modules/system/core.api.php @@ -412,7 +412,7 @@ * * Example: * @code - * $cid = 'mymodule_example:' . \Drupal::languageManager()->getCurrentLanguage()->id(); + * $cid = 'mymodule_example:' . \Drupal::languageManager()->getCurrentLanguage()->getId(); * * $data = NULL; * if ($cache = \Drupal::cache()->get($cid)) { diff --git a/core/modules/system/language.api.php b/core/modules/system/language.api.php index ed6de6c..f90a1fe 100644 --- a/core/modules/system/language.api.php +++ b/core/modules/system/language.api.php @@ -27,8 +27,8 @@ function hook_language_switch_links_alter(array &$links, $type, $path) { $language_interface = \Drupal::languageManager()->getCurrentLanguage(); - if ($type == \Drupal\Core\Language\Language::TYPE_CONTENT && isset($links[$language_interface->id])) { - foreach ($links[$language_interface->id] as $link) { + if ($type == \Drupal\Core\Language\LanguageInterface::TYPE_CONTENT && isset($links[$language_interface->id])) { + foreach ($links[$language_interface->getId()] as $link) { $link['attributes']['class'][] = 'active-language'; } } diff --git a/core/modules/system/lib/Drupal/system/Form/DateFormatFormBase.php b/core/modules/system/lib/Drupal/system/Form/DateFormatFormBase.php index 3dfb81e..0d7f8fb 100644 --- a/core/modules/system/lib/Drupal/system/Form/DateFormatFormBase.php +++ b/core/modules/system/lib/Drupal/system/Form/DateFormatFormBase.php @@ -11,7 +11,7 @@ use Drupal\Core\Ajax\ReplaceCommand; use Drupal\Core\Config\Entity\ConfigEntityStorageInterface; use Drupal\Core\Datetime\Date; -use Drupal\Core\Language\Language; +use Drupal\Core\Language\LanguageInterface; use Symfony\Component\DependencyInjection\ContainerInterface; use Drupal\Core\Datetime\DrupalDateTime; use Drupal\Core\Entity\EntityForm; @@ -160,7 +160,7 @@ public function form(array $form, array &$form_state) { $form['langcode'] = array( '#type' => 'language_select', '#title' => t('Language'), - '#languages' => Language::STATE_ALL, + '#languages' => LanguageInterface::STATE_ALL, '#default_value' => $this->entity->langcode, ); diff --git a/core/modules/system/lib/Drupal/system/Tests/Common/FormatDateTest.php b/core/modules/system/lib/Drupal/system/Tests/Common/FormatDateTest.php index 171b915..3ddbf14 100644 --- a/core/modules/system/lib/Drupal/system/Tests/Common/FormatDateTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/Common/FormatDateTest.php @@ -8,6 +8,7 @@ namespace Drupal\system\Tests\Common; use Drupal\Core\Language\Language; +use Drupal\Core\Language\LanguageInterface; use Drupal\simpletest\WebTestBase; /** @@ -113,7 +114,7 @@ function testFormatDate() { 'predefined_langcode' => 'custom', 'langcode' => self::LANGCODE, 'name' => self::LANGCODE, - 'direction' => Language::DIRECTION_LTR, + 'direction' => LanguageInterface::DIRECTION_LTR, ); $this->drupalPostForm('admin/config/regional/language/add', $edit, t('Add custom language')); @@ -132,8 +133,8 @@ function testFormatDate() { // Save the original user and language and then replace it with the test user and language. $real_user = $user; $user = user_load($test_user->id(), TRUE); - $real_language = $language_interface->id; - $language_interface->id = $user->getPreferredLangcode(); + $real_language = $language_interface->getId(); + $language_interface->setId($user->getPreferredLangcode()); // Simulate a Drupal bootstrap with the logged-in user. date_default_timezone_set(drupal_get_user_timezone()); @@ -155,7 +156,7 @@ function testFormatDate() { // Restore the original user and language, and enable session saving. $user = $real_user; - $language_interface->id = $real_language; + $language_interface->setId($real_language); // Restore default time zone. date_default_timezone_set(drupal_get_user_timezone()); \Drupal::service('session_manager')->enable(); diff --git a/core/modules/system/lib/Drupal/system/Tests/Common/UrlTest.php b/core/modules/system/lib/Drupal/system/Tests/Common/UrlTest.php index 7cda6a3..d59492d 100644 --- a/core/modules/system/lib/Drupal/system/Tests/Common/UrlTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/Common/UrlTest.php @@ -66,7 +66,7 @@ function testLinkAttributes() { '#href' => 'http://drupal.org', '#title' => 'bar', ); - $langcode = $language->id; + $langcode = $language->getId(); // Test that the default hreflang handling for links does not override a // hreflang attribute explicitly set in the render array. diff --git a/core/modules/system/lib/Drupal/system/Tests/Entity/EntityCrudHookTest.php b/core/modules/system/lib/Drupal/system/Tests/Entity/EntityCrudHookTest.php index 1d49a02..0c19fff 100644 --- a/core/modules/system/lib/Drupal/system/Tests/Entity/EntityCrudHookTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/Entity/EntityCrudHookTest.php @@ -8,7 +8,7 @@ namespace Drupal\system\Tests\Entity; use Drupal\comment\Plugin\Field\FieldType\CommentItemInterface; -use Drupal\Core\Language\Language; +use Drupal\Core\Language\LanguageInterface; use Drupal\Core\Database\Database; /** @@ -148,7 +148,7 @@ public function testCommentHooks() { 'status' => 1, 'promote' => 0, 'sticky' => 0, - 'langcode' => Language::LANGCODE_NOT_SPECIFIED, + 'langcode' => LanguageInterface::LANGCODE_NOT_SPECIFIED, 'created' => REQUEST_TIME, 'changed' => REQUEST_TIME, )); @@ -167,7 +167,7 @@ public function testCommentHooks() { 'created' => REQUEST_TIME, 'changed' => REQUEST_TIME, 'status' => 1, - 'langcode' => Language::LANGCODE_NOT_SPECIFIED, + 'langcode' => LanguageInterface::LANGCODE_NOT_SPECIFIED, )); $this->assertHookMessageOrder(array( @@ -292,7 +292,7 @@ public function testNodeHooks() { 'status' => 1, 'promote' => 0, 'sticky' => 0, - 'langcode' => Language::LANGCODE_NOT_SPECIFIED, + 'langcode' => LanguageInterface::LANGCODE_NOT_SPECIFIED, 'created' => REQUEST_TIME, 'changed' => REQUEST_TIME, )); @@ -351,7 +351,7 @@ public function testTaxonomyTermHooks() { $vocabulary = entity_create('taxonomy_vocabulary', array( 'name' => 'Test vocabulary', 'vid' => 'test', - 'langcode' => Language::LANGCODE_NOT_SPECIFIED, + 'langcode' => LanguageInterface::LANGCODE_NOT_SPECIFIED, 'description' => NULL, 'module' => 'entity_crud_hook_test', )); @@ -361,7 +361,7 @@ public function testTaxonomyTermHooks() { $term = entity_create('taxonomy_term', array( 'vid' => $vocabulary->id(), 'name' => 'Test term', - 'langcode' => Language::LANGCODE_NOT_SPECIFIED, + 'langcode' => LanguageInterface::LANGCODE_NOT_SPECIFIED, 'description' => NULL, 'format' => 1, )); @@ -420,7 +420,7 @@ public function testTaxonomyVocabularyHooks() { $vocabulary = entity_create('taxonomy_vocabulary', array( 'name' => 'Test vocabulary', 'vid' => 'test', - 'langcode' => Language::LANGCODE_NOT_SPECIFIED, + 'langcode' => LanguageInterface::LANGCODE_NOT_SPECIFIED, 'description' => NULL, 'module' => 'entity_crud_hook_test', )); diff --git a/core/modules/system/lib/Drupal/system/Tests/Entity/EntityFieldDefaultValueTest.php b/core/modules/system/lib/Drupal/system/Tests/Entity/EntityFieldDefaultValueTest.php index d624080..8f7e23f 100644 --- a/core/modules/system/lib/Drupal/system/Tests/Entity/EntityFieldDefaultValueTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/Entity/EntityFieldDefaultValueTest.php @@ -7,7 +7,7 @@ namespace Drupal\system\Tests\Entity; -use Drupal\Core\Language\Language; +use Drupal\Core\Language\LanguageInterface; use Drupal\Component\Uuid\Uuid; use Drupal\Component\Utility\String; @@ -55,7 +55,7 @@ public function testDefaultValues() { */ protected function assertDefaultValues($entity_type) { $entity = entity_create($entity_type); - $this->assertEqual($entity->langcode->value, Language::LANGCODE_NOT_SPECIFIED, String::format('%entity_type: Default language', array('%entity_type' => $entity_type))); + $this->assertEqual($entity->langcode->value, LanguageInterface::LANGCODE_NOT_SPECIFIED, String::format('%entity_type: Default language', array('%entity_type' => $entity_type))); $this->assertTrue(Uuid::isValid($entity->uuid->value), String::format('%entity_type: Default UUID', array('%entity_type' => $entity_type))); $this->assertEqual($entity->name->getValue(), array(0 => array('value' => NULL)), 'Field has one empty value by default.'); } diff --git a/core/modules/system/lib/Drupal/system/Tests/Entity/EntityFieldTest.php b/core/modules/system/lib/Drupal/system/Tests/Entity/EntityFieldTest.php index a838d2f..f593dfc 100644 --- a/core/modules/system/lib/Drupal/system/Tests/Entity/EntityFieldTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/Entity/EntityFieldTest.php @@ -12,7 +12,7 @@ use Drupal\Core\Field\FieldDefinitionInterface; use Drupal\Core\Field\FieldItemListInterface; use Drupal\Core\Field\FieldItemInterface; -use Drupal\Core\Language\Language; +use Drupal\Core\Language\LanguageInterface; use Drupal\Core\TypedData\ComplexDataDefinitionInterface; use Drupal\Core\TypedData\DataDefinitionInterface; use Drupal\Core\TypedData\Type\StringInterface; @@ -190,18 +190,18 @@ protected function assertReadWrite($entity_type) { $this->assertFalse(isset($entity->name->value), format_string('%entity_type: Name is not set.', array('%entity_type' => $entity_type))); // Access the language field. - $this->assertEqual(Language::LANGCODE_NOT_SPECIFIED, $entity->langcode->value, format_string('%entity_type: Language code can be read.', array('%entity_type' => $entity_type))); - $this->assertEqual(\Drupal::languageManager()->getLanguage(Language::LANGCODE_NOT_SPECIFIED), $entity->langcode->language, format_string('%entity_type: Language object can be read.', array('%entity_type' => $entity_type))); + $this->assertEqual(LanguageInterface::LANGCODE_NOT_SPECIFIED, $entity->langcode->value, format_string('%entity_type: Language code can be read.', array('%entity_type' => $entity_type))); + $this->assertEqual(\Drupal::languageManager()->getLanguage(LanguageInterface::LANGCODE_NOT_SPECIFIED), $entity->langcode->language, format_string('%entity_type: Language object can be read.', array('%entity_type' => $entity_type))); // Change the language by code. - $entity->langcode->value = \Drupal::languageManager()->getDefaultLanguage()->id; - $this->assertEqual(\Drupal::languageManager()->getDefaultLanguage()->id, $entity->langcode->value, format_string('%entity_type: Language code can be read.', array('%entity_type' => $entity_type))); + $entity->langcode->value = \Drupal::languageManager()->getDefaultLanguage()->getId(); + $this->assertEqual(\Drupal::languageManager()->getDefaultLanguage()->getId(), $entity->langcode->value, format_string('%entity_type: Language code can be read.', array('%entity_type' => $entity_type))); $this->assertEqual(\Drupal::languageManager()->getDefaultLanguage(), $entity->langcode->language, format_string('%entity_type: Language object can be read.', array('%entity_type' => $entity_type))); // Revert language by code then try setting it by language object. - $entity->langcode->value = Language::LANGCODE_NOT_SPECIFIED; + $entity->langcode->value = LanguageInterface::LANGCODE_NOT_SPECIFIED; $entity->langcode->language = \Drupal::languageManager()->getDefaultLanguage(); - $this->assertEqual(\Drupal::languageManager()->getDefaultLanguage()->id, $entity->langcode->value, format_string('%entity_type: Language code can be read.', array('%entity_type' => $entity_type))); + $this->assertEqual(\Drupal::languageManager()->getDefaultLanguage()->getId(), $entity->langcode->value, format_string('%entity_type: Language code can be read.', array('%entity_type' => $entity_type))); $this->assertEqual(\Drupal::languageManager()->getDefaultLanguage(), $entity->langcode->language, format_string('%entity_type: Language object can be read.', array('%entity_type' => $entity_type))); // Access the text field and test updating. @@ -329,8 +329,8 @@ protected function assertSave($entity_type) { // Access the name field. $this->assertEqual(1, $entity->id->value, format_string('%entity_type: ID value can be read.', array('%entity_type' => $entity_type))); $this->assertTrue(is_string($entity->uuid->value), format_string('%entity_type: UUID value can be read.', array('%entity_type' => $entity_type))); - $this->assertEqual(Language::LANGCODE_NOT_SPECIFIED, $entity->langcode->value, format_string('%entity_type: Language code can be read.', array('%entity_type' => $entity_type))); - $this->assertEqual(\Drupal::languageManager()->getLanguage(Language::LANGCODE_NOT_SPECIFIED), $entity->langcode->language, format_string('%entity_type: Language object can be read.', array('%entity_type' => $entity_type))); + $this->assertEqual(LanguageInterface::LANGCODE_NOT_SPECIFIED, $entity->langcode->value, format_string('%entity_type: Language code can be read.', array('%entity_type' => $entity_type))); + $this->assertEqual(\Drupal::languageManager()->getLanguage(LanguageInterface::LANGCODE_NOT_SPECIFIED), $entity->langcode->language, format_string('%entity_type: Language object can be read.', array('%entity_type' => $entity_type))); $this->assertEqual($this->entity_user->id(), $entity->user_id->target_id, format_string('%entity_type: User id can be read.', array('%entity_type' => $entity_type))); $this->assertEqual($this->entity_user->getUsername(), $entity->user_id->entity->name->value, format_string('%entity_type: User name can be read.', array('%entity_type' => $entity_type))); $this->assertEqual($this->entity_field_text, $entity->field_test_text->value, format_string('%entity_type: Text field can be read.', array('%entity_type' => $entity_type))); @@ -504,7 +504,7 @@ protected function assertDataStructureInterfaces($entity_type) { // the user name and other user entity strings as well. $target_strings = array( $entity->uuid->value, - Language::LANGCODE_NOT_SPECIFIED, + LanguageInterface::LANGCODE_NOT_SPECIFIED, $this->entity_name, // Bundle name. $entity->bundle(), diff --git a/core/modules/system/lib/Drupal/system/Tests/Entity/EntityLanguageTestBase.php b/core/modules/system/lib/Drupal/system/Tests/Entity/EntityLanguageTestBase.php index ada2fbd..91a6bae 100644 --- a/core/modules/system/lib/Drupal/system/Tests/Entity/EntityLanguageTestBase.php +++ b/core/modules/system/lib/Drupal/system/Tests/Entity/EntityLanguageTestBase.php @@ -106,7 +106,7 @@ function setUp() { // Create the default languages. $default_language = language_save($this->languageManager->getDefaultLanguage()); - $languages = $this->languageManager->getDefaultLockedLanguages($default_language->weight); + $languages = $this->languageManager->getDefaultLockedLanguages($default_language->getWeight()); foreach ($languages as $language) { language_save($language); } @@ -119,7 +119,7 @@ function setUp() { 'name' => $this->randomString(), 'weight' => $i, )); - $this->langcodes[$i] = $language->id; + $this->langcodes[$i] = $language->getId(); language_save($language); } } diff --git a/core/modules/system/lib/Drupal/system/Tests/Entity/EntityTranslationFormTest.php b/core/modules/system/lib/Drupal/system/Tests/Entity/EntityTranslationFormTest.php index 8c0288e..1d5c15b 100644 --- a/core/modules/system/lib/Drupal/system/Tests/Entity/EntityTranslationFormTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/Entity/EntityTranslationFormTest.php @@ -8,6 +8,7 @@ namespace Drupal\system\Tests\Entity; use Drupal\field\Entity\FieldConfig; +use Drupal\Core\Language\LanguageInterface; use Drupal\simpletest\WebTestBase; use Drupal\Core\Language\Language; @@ -45,7 +46,7 @@ function setUp() { 'id' => 'l' . $i, 'name' => $this->randomString(), )); - $this->langcodes[$i] = $language->id; + $this->langcodes[$i] = $language->getId(); language_save($language); } } @@ -59,7 +60,7 @@ function testEntityFormLanguage() { $web_user = $this->drupalCreateUser(array('create page content', 'edit own page content', 'administer content types')); $this->drupalLogin($web_user); - // Create a node with language Language::LANGCODE_NOT_SPECIFIED. + // Create a node with language LanguageInterface::LANGCODE_NOT_SPECIFIED. $edit = array(); $edit['title[0][value]'] = $this->randomName(8); $edit['body[0][value]'] = $this->randomName(16); @@ -69,12 +70,12 @@ function testEntityFormLanguage() { $this->drupalPostForm(NULL, $edit, t('Save')); $node = $this->drupalGetNodeByTitle($edit['title[0][value]']); - $this->assertTrue($node->language()->id == $form_langcode, 'Form language is the same as the entity language.'); + $this->assertTrue($node->language()->getId() == $form_langcode, 'Form language is the same as the entity language.'); // Edit the node and test the form language. $this->drupalGet($this->langcodes[0] . '/node/' . $node->id() . '/edit'); $form_langcode = \Drupal::state()->get('entity_test.form_langcode') ?: FALSE; - $this->assertTrue($node->language()->id == $form_langcode, 'Form language is the same as the entity language.'); + $this->assertTrue($node->language()->getId() == $form_langcode, 'Form language is the same as the entity language.'); // Explicitly set form langcode. $langcode = $this->langcodes[0]; @@ -85,7 +86,7 @@ function testEntityFormLanguage() { // Enable language selector. $this->drupalGet('admin/structure/types/manage/page'); - $edit = array('language_configuration[language_show]' => TRUE, 'language_configuration[langcode]' => Language::LANGCODE_NOT_SPECIFIED); + $edit = array('language_configuration[language_show]' => TRUE, 'language_configuration[langcode]' => LanguageInterface::LANGCODE_NOT_SPECIFIED); $this->drupalPostForm('admin/structure/types/manage/page', $edit, t('Save content type')); $this->assertRaw(t('The content type %type has been updated.', array('%type' => 'Basic page')), 'Basic page content type has been updated.'); diff --git a/core/modules/system/lib/Drupal/system/Tests/Entity/EntityTranslationTest.php b/core/modules/system/lib/Drupal/system/Tests/Entity/EntityTranslationTest.php index 2086c14..1e5a08a 100644 --- a/core/modules/system/lib/Drupal/system/Tests/Entity/EntityTranslationTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/Entity/EntityTranslationTest.php @@ -7,7 +7,7 @@ namespace Drupal\system\Tests\Entity; -use Drupal\Core\Language\Language; +use Drupal\Core\Language\LanguageInterface; use Drupal\entity_test\Entity\EntityTestMulRev; /** @@ -44,15 +44,15 @@ protected function _testEntityLanguageMethods($entity_type) { 'name' => 'test', 'user_id' => $this->container->get('current_user')->id(), )); - $this->assertEqual($entity->language()->id, Language::LANGCODE_NOT_SPECIFIED, format_string('%entity_type: Entity language not specified.', array('%entity_type' => $entity_type))); + $this->assertEqual($entity->language()->getId(), LanguageInterface::LANGCODE_NOT_SPECIFIED, format_string('%entity_type: Entity language not specified.', array('%entity_type' => $entity_type))); $this->assertFalse($entity->getTranslationLanguages(FALSE), format_string('%entity_type: No translations are available', array('%entity_type' => $entity_type))); // Set the value in default language. $entity->set($this->field_name, array(0 => array('value' => 'default value'))); // Get the value. - $field = $entity->getTranslation(Language::LANGCODE_DEFAULT)->get($this->field_name); + $field = $entity->getTranslation(LanguageInterface::LANGCODE_DEFAULT)->get($this->field_name); $this->assertEqual($field->value, 'default value', format_string('%entity_type: Untranslated value retrieved.', array('%entity_type' => $entity_type))); - $this->assertEqual($field->getLangcode(), Language::LANGCODE_NOT_SPECIFIED, format_string('%entity_type: Field object has the expected langcode.', array('%entity_type' => $entity_type))); + $this->assertEqual($field->getLangcode(), LanguageInterface::LANGCODE_NOT_SPECIFIED, format_string('%entity_type: Field object has the expected langcode.', array('%entity_type' => $entity_type))); // Set the value in a certain language. As the entity is not // language-specific it should use the default language and so ignore the @@ -65,7 +65,7 @@ protected function _testEntityLanguageMethods($entity_type) { // language-specific entity. $field = $entity->getTranslation($this->langcodes[1])->get($this->field_name); $this->assertEqual($field->value, 'default value2', format_string('%entity_type: Untranslated value retrieved.', array('%entity_type' => $entity_type))); - $this->assertEqual($field->getLangcode(), Language::LANGCODE_NOT_SPECIFIED, format_string('%entity_type: Field object has the expected langcode.', array('%entity_type' => $entity_type))); + $this->assertEqual($field->getLangcode(), LanguageInterface::LANGCODE_NOT_SPECIFIED, format_string('%entity_type: Field object has the expected langcode.', array('%entity_type' => $entity_type))); // Now, make the entity language-specific by assigning a language and test // translating it. @@ -152,12 +152,12 @@ protected function _testMultilingualProperties($entity_type) { $entity = entity_create($entity_type, array('name' => $name, 'user_id' => $uid)); $entity->save(); $entity = entity_load($entity_type, $entity->id()); - $default_langcode = $entity->language()->id; - $this->assertEqual($default_langcode, Language::LANGCODE_NOT_SPECIFIED, format_string('%entity_type: Entity created as language neutral.', array('%entity_type' => $entity_type))); - $field = $entity->getTranslation(Language::LANGCODE_DEFAULT)->get('name'); + $default_langcode = $entity->language()->getId(); + $this->assertEqual($default_langcode, LanguageInterface::LANGCODE_NOT_SPECIFIED, format_string('%entity_type: Entity created as language neutral.', array('%entity_type' => $entity_type))); + $field = $entity->getTranslation(LanguageInterface::LANGCODE_DEFAULT)->get('name'); $this->assertEqual($name, $field->value, format_string('%entity_type: The entity name has been correctly stored as language neutral.', array('%entity_type' => $entity_type))); $this->assertEqual($default_langcode, $field->getLangcode(), format_string('%entity_type: The field object has the expect langcode.', array('%entity_type' => $entity_type))); - $this->assertEqual($uid, $entity->getTranslation(Language::LANGCODE_DEFAULT)->get('user_id')->target_id, format_string('%entity_type: The entity author has been correctly stored as language neutral.', array('%entity_type' => $entity_type))); + $this->assertEqual($uid, $entity->getTranslation(LanguageInterface::LANGCODE_DEFAULT)->get('user_id')->target_id, format_string('%entity_type: The entity author has been correctly stored as language neutral.', array('%entity_type' => $entity_type))); $field = $entity->getTranslation($langcode)->get('name'); $this->assertEqual($name, $field->value, format_string('%entity_type: The entity name defaults to neutral language.', array('%entity_type' => $entity_type))); $this->assertEqual($default_langcode, $field->getLangcode(), format_string('%entity_type: The field object has the expect langcode.', array('%entity_type' => $entity_type))); @@ -172,18 +172,18 @@ protected function _testMultilingualProperties($entity_type) { $entity = entity_create($entity_type, array('name' => $name, 'user_id' => $uid, 'langcode' => $langcode)); $entity->save(); $entity = entity_load($entity_type, $entity->id()); - $default_langcode = $entity->language()->id; + $default_langcode = $entity->language()->getId(); $this->assertEqual($default_langcode, $langcode, format_string('%entity_type: Entity created as language specific.', array('%entity_type' => $entity_type))); $field = $entity->getTranslation($langcode)->get('name'); $this->assertEqual($name, $field->value, format_string('%entity_type: The entity name has been correctly stored as a language-aware property.', array('%entity_type' => $entity_type))); $this->assertEqual($default_langcode, $field->getLangcode(), format_string('%entity_type: The field object has the expect langcode.', array('%entity_type' => $entity_type))); $this->assertEqual($uid, $entity->getTranslation($langcode)->get('user_id')->target_id, format_string('%entity_type: The entity author has been correctly stored as a language-aware property.', array('%entity_type' => $entity_type))); // Translatable properties on a translatable entity should use default - // language if Language::LANGCODE_NOT_SPECIFIED is passed. - $field = $entity->getTranslation(Language::LANGCODE_NOT_SPECIFIED)->get('name'); + // language if LanguageInterface::LANGCODE_NOT_SPECIFIED is passed. + $field = $entity->getTranslation(LanguageInterface::LANGCODE_NOT_SPECIFIED)->get('name'); $this->assertEqual($name, $field->value, format_string('%entity_type: The entity name defaults to the default language.', array('%entity_type' => $entity_type))); $this->assertEqual($default_langcode, $field->getLangcode(), format_string('%entity_type: The field object has the expect langcode.', array('%entity_type' => $entity_type))); - $this->assertEqual($uid, $entity->getTranslation(Language::LANGCODE_NOT_SPECIFIED)->get('user_id')->target_id, format_string('%entity_type: The entity author defaults to the default language.', array('%entity_type' => $entity_type))); + $this->assertEqual($uid, $entity->getTranslation(LanguageInterface::LANGCODE_NOT_SPECIFIED)->get('user_id')->target_id, format_string('%entity_type: The entity author defaults to the default language.', array('%entity_type' => $entity_type))); $field = $entity->get('name'); $this->assertEqual($name, $field->value, format_string('%entity_type: The entity name can be retrieved without specifying a language.', array('%entity_type' => $entity_type))); $this->assertEqual($default_langcode, $field->getLangcode(), format_string('%entity_type: The field object has the expect langcode.', array('%entity_type' => $entity_type))); @@ -221,7 +221,7 @@ protected function _testMultilingualProperties($entity_type) { ); $field = $entity->getTranslation($langcode)->get('name'); $this->assertEqual($properties[$langcode]['name'][0], $field->value, format_string('%entity_type: The entity name has been correctly stored for language %langcode.', $args)); - $field_langcode = ($langcode == $entity->language()->id) ? $default_langcode : $langcode; + $field_langcode = ($langcode == $entity->language()->getId()) ? $default_langcode : $langcode; $this->assertEqual($field_langcode, $field->getLangcode(), format_string('%entity_type: The field object has the expected langcode %langcode.', $args)); $this->assertEqual($properties[$langcode]['user_id'][0], $entity->getTranslation($langcode)->get('user_id')->target_id, format_string('%entity_type: The entity author has been correctly stored for language %langcode.', $args)); } @@ -309,7 +309,7 @@ function testEntityTranslationAPI() { $entity->langcode->value = $default_langcode; $translation = $entity->getTranslation($default_langcode); $this->assertEqual($entity, $translation, 'The translation object corresponding to the default language (explicit) is the entity object itself.'); - $translation = $entity->getTranslation(Language::LANGCODE_DEFAULT); + $translation = $entity->getTranslation(LanguageInterface::LANGCODE_DEFAULT); $this->assertEqual($entity, $translation, 'The translation object corresponding to the default language (implicit) is the entity object itself.'); // Create a translation and verify that the translation object and the @@ -320,8 +320,8 @@ function testEntityTranslationAPI() { $translation = $entity->addTranslation($langcode); $this->assertNotIdentical($entity, $translation, 'The entity and the translation object differ from one another.'); $this->assertTrue($entity->hasTranslation($langcode), 'The new translation exists.'); - $this->assertEqual($translation->language()->id, $langcode, 'The translation language matches the specified one.'); - $this->assertEqual($translation->getUntranslated()->language()->id, $default_langcode, 'The original language can still be retrieved.'); + $this->assertEqual($translation->language()->getId(), $langcode, 'The translation language matches the specified one.'); + $this->assertEqual($translation->getUntranslated()->language()->getId(), $default_langcode, 'The original language can still be retrieved.'); $translation->name->value = $name_translated; $this->assertEqual($entity->name->value, $name, 'The original name is retained after setting a translated value.'); $entity->name->value = $name; @@ -335,16 +335,16 @@ function testEntityTranslationAPI() { // Check that after loading an entity the language is the default one. $entity = $this->reloadEntity($entity); - $this->assertEqual($entity->language()->id, $default_langcode, 'The loaded entity is the original one.'); + $this->assertEqual($entity->language()->getId(), $default_langcode, 'The loaded entity is the original one.'); // Add another translation and check that everything works as expected. A // new translation object can be obtained also by just specifying a valid // language. $langcode2 = $this->langcodes[2]; $translation = $entity->getTranslation($langcode2); - $value = $entity !== $translation && $translation->language()->id == $langcode2 && $entity->hasTranslation($langcode2); + $value = $entity !== $translation && $translation->language()->getId() == $langcode2 && $entity->hasTranslation($langcode2); $this->assertTrue($value, 'A new translation object can be obtained also by specifying a valid language.'); - $this->assertEqual($entity->language()->id, $default_langcode, 'The original language has been preserved.'); + $this->assertEqual($entity->language()->getId(), $default_langcode, 'The original language has been preserved.'); $translation->save(); $hooks = $this->getHooksInfo(); $this->assertEqual($hooks['entity_translation_insert'], $langcode2, 'The generic entity translation insertion hook has fired.'); @@ -377,7 +377,7 @@ function testEntityTranslationAPI() { // Check that removing an invalid translation causes an exception to be // thrown. - foreach (array($default_langcode, Language::LANGCODE_DEFAULT, $this->randomName()) as $invalid_langcode) { + foreach (array($default_langcode, LanguageInterface::LANGCODE_DEFAULT, $this->randomName()) as $invalid_langcode) { $message = format_string('Removing an invalid translation (@langcode) causes an exception to be thrown.', array('@langcode' => $invalid_langcode)); try { $entity->removeTranslation($invalid_langcode); @@ -448,7 +448,7 @@ function testEntityTranslationAPI() { * Tests language fallback applied to field and entity translations. */ function testLanguageFallback() { - $current_langcode = $this->languageManager->getCurrentLanguage(Language::TYPE_CONTENT)->id; + $current_langcode = $this->languageManager->getCurrentLanguage(LanguageInterface::TYPE_CONTENT)->getId(); $this->langcodes[] = $current_langcode; $values = array(); @@ -472,21 +472,21 @@ function testLanguageFallback() { // Check that retrieveing the current translation works as expected. $entity = $this->reloadEntity($entity); $translation = $this->entityManager->getTranslationFromContext($entity, $langcode2); - $this->assertEqual($translation->language()->id, $default_langcode, 'The current translation language matches the expected one.'); + $this->assertEqual($translation->language()->getId(), $default_langcode, 'The current translation language matches the expected one.'); // Check that language fallback respects language weight by default. $languages = $this->languageManager->getLanguages(); - $languages[$langcode]->weight = -1; + $languages[$langcode]->setWeight(-1); language_save($languages[$langcode]); $translation = $this->entityManager->getTranslationFromContext($entity, $langcode2); - $this->assertEqual($translation->language()->id, $langcode, 'The current translation language matches the expected one.'); + $this->assertEqual($translation->language()->getId(), $langcode, 'The current translation language matches the expected one.'); // Check that the current translation is properly returned. $translation = $this->entityManager->getTranslationFromContext($entity); - $this->assertEqual($langcode, $translation->language()->id, 'The current translation language matches the topmost language fallback candidate.'); + $this->assertEqual($langcode, $translation->language()->getId(), 'The current translation language matches the topmost language fallback candidate.'); $entity->addTranslation($current_langcode, $values[$current_langcode]); $translation = $this->entityManager->getTranslationFromContext($entity); - $this->assertEqual($current_langcode, $translation->language()->id, 'The current translation language matches the current language.'); + $this->assertEqual($current_langcode, $translation->language()->getId(), 'The current translation language matches the current language.'); // Check that if the entity has no translation no fallback is applied. $entity2 = $controller->create(array('langcode' => $default_langcode)); diff --git a/core/modules/system/lib/Drupal/system/Tests/Entity/FieldSqlStorageTest.php b/core/modules/system/lib/Drupal/system/Tests/Entity/FieldSqlStorageTest.php index 8549d99..866cc9c 100644 --- a/core/modules/system/lib/Drupal/system/Tests/Entity/FieldSqlStorageTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/Entity/FieldSqlStorageTest.php @@ -117,13 +117,13 @@ function testFieldLoad() { for ($delta = 0; $delta <= $this->field_cardinality; $delta++) { $value = mt_rand(1, 127); $values[$revision_id][] = $value; - $query->values(array($bundle, 0, $entity->id(), $revision_id, $delta, $entity->language()->id, $value)); + $query->values(array($bundle, 0, $entity->id(), $revision_id, $delta, $entity->language()->getId(), $value)); } $query->execute(); } $query = db_insert($this->table)->fields($columns); foreach ($values[$revision_id] as $delta => $value) { - $query->values(array($bundle, 0, $entity->id(), $revision_id, $delta, $entity->language()->id, $value)); + $query->values(array($bundle, 0, $entity->id(), $revision_id, $delta, $entity->language()->getId(), $value)); } $query->execute(); @@ -187,7 +187,7 @@ function testFieldWrite() { 'deleted' => 0, 'entity_id' => $entity->id(), 'revision_id' => $entity->getRevisionId(), - 'langcode' => $entity->language()->id, + 'langcode' => $entity->language()->getId(), 'delta' => $delta, $this->field_name . '_value' => $values[$delta]['value'], ); @@ -210,7 +210,7 @@ function testFieldWrite() { 'deleted' => 0, 'entity_id' => $entity->id(), 'revision_id' => $entity->getRevisionId(), - 'langcode' => $entity->language()->id, + 'langcode' => $entity->language()->getId(), 'delta' => $delta, $this->field_name . '_value' => $values[$delta]['value'], ); @@ -238,7 +238,7 @@ function testFieldWrite() { 'deleted' => 0, 'entity_id' => $entity->id(), 'revision_id' => $revision_id, - 'langcode' => $entity->language()->id, + 'langcode' => $entity->language()->getId(), 'delta' => $delta, $this->field_name . '_value' => $values[$delta]['value'], ); diff --git a/core/modules/system/lib/Drupal/system/Tests/Entity/FieldTranslationSqlStorageTest.php b/core/modules/system/lib/Drupal/system/Tests/Entity/FieldTranslationSqlStorageTest.php index b9d8cec..ec3425a 100644 --- a/core/modules/system/lib/Drupal/system/Tests/Entity/FieldTranslationSqlStorageTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/Entity/FieldTranslationSqlStorageTest.php @@ -11,6 +11,7 @@ use Drupal\Core\Entity\ContentEntityDatabaseStorage; use Drupal\Core\Language\Language; use Drupal\field\Entity\FieldConfig; +use Drupal\Core\Language\LanguageInterface; /** * Tests entity translation. @@ -48,7 +49,7 @@ public function testFieldSqlStorage() { $entity->langcode->value = $langcode; $entity->save(); $this->assertFieldStorageLangcode($entity, 'Field language successfully changed.'); - $langcode = Language::LANGCODE_NOT_SPECIFIED; + $langcode = LanguageInterface::LANGCODE_NOT_SPECIFIED; $entity->langcode->value = $langcode; $entity->save(); $this->assertFieldStorageLangcode($entity, 'Field language successfully changed to language neutral.'); @@ -87,7 +88,7 @@ protected function assertFieldStorageLangcode(ContentEntityInterface $entity, $m $status = TRUE; $entity_type = $entity->getEntityTypeId(); $id = $entity->id(); - $langcode = $entity->getUntranslated()->language()->id; + $langcode = $entity->getUntranslated()->language()->getId(); $fields = array($this->field_name, $this->untranslatable_field_name); foreach ($fields as $field_name) { diff --git a/core/modules/system/lib/Drupal/system/Tests/Form/LanguageSelectElementTest.php b/core/modules/system/lib/Drupal/system/Tests/Form/LanguageSelectElementTest.php index f501ad1..991cdde 100644 --- a/core/modules/system/lib/Drupal/system/Tests/Form/LanguageSelectElementTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/Form/LanguageSelectElementTest.php @@ -10,6 +10,7 @@ use Drupal\Component\Serialization\Json; use Drupal\simpletest\WebTestBase; use Drupal\Core\Language\Language; +use Drupal\Core\Language\LanguageInterface; /** * Functional tests for the language select form element. @@ -52,15 +53,15 @@ function testLanguageSelectElementOptions() { $this->drupalGet('form-test/language_select'); // Check that the language fields were rendered on the page. - $ids = array('edit-languages-all' => Language::STATE_ALL, - 'edit-languages-configurable' => Language::STATE_CONFIGURABLE, - 'edit-languages-locked' => Language::STATE_LOCKED, - 'edit-languages-config-and-locked' => Language::STATE_CONFIGURABLE | Language::STATE_LOCKED); + $ids = array('edit-languages-all' => LanguageInterface::STATE_ALL, + 'edit-languages-configurable' => LanguageInterface::STATE_CONFIGURABLE, + 'edit-languages-locked' => LanguageInterface::STATE_LOCKED, + 'edit-languages-config-and-locked' => LanguageInterface::STATE_CONFIGURABLE | LanguageInterface::STATE_LOCKED); foreach ($ids as $id => $flags) { $this->assertField($id, format_string('The @id field was found on the page.', array('@id' => $id))); $options = array(); foreach ($this->container->get('language_manager')->getLanguages($flags) as $langcode => $language) { - $options[$langcode] = $language->locked ? t('- @name -', array('@name' => $language->name)) : $language->name; + $options[$langcode] = $language->isLocked() ? t('- @name -', array('@name' => $language->getName())) : $language->getName(); } $this->_testLanguageSelectElementOptions($id, $options); } @@ -93,7 +94,7 @@ function testHiddenLanguageSelectElement() { $values = Json::decode($this->drupalGetContent()); $this->assertEqual($values['languages_all'], 'xx'); $this->assertEqual($values['languages_configurable'], 'en'); - $this->assertEqual($values['languages_locked'], Language::LANGCODE_NOT_SPECIFIED); + $this->assertEqual($values['languages_locked'], LanguageInterface::LANGCODE_NOT_SPECIFIED); $this->assertEqual($values['languages_config_and_locked'], 'dummy_value'); $this->assertEqual($values['language_custom_options'], 'opt2'); } diff --git a/core/modules/system/lib/Drupal/system/Tests/KeyValueStore/KeyValueContentEntityStorageTest.php b/core/modules/system/lib/Drupal/system/Tests/KeyValueStore/KeyValueContentEntityStorageTest.php index 10aec9b..5930939 100644 --- a/core/modules/system/lib/Drupal/system/Tests/KeyValueStore/KeyValueContentEntityStorageTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/KeyValueStore/KeyValueContentEntityStorageTest.php @@ -38,7 +38,7 @@ public static function getInfo() { * Tests CRUD operations. */ function testCRUD() { - $default_langcode = language_default()->id; + $default_langcode = language_default()->getId(); // Verify default properties on a newly created empty entity. $empty = entity_create('entity_test_label'); $this->assertIdentical($empty->id->value, NULL); diff --git a/core/modules/system/lib/Drupal/system/Tests/Mail/MailTest.php b/core/modules/system/lib/Drupal/system/Tests/Mail/MailTest.php index 56aef7f..22443f2 100644 --- a/core/modules/system/lib/Drupal/system/Tests/Mail/MailTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/Mail/MailTest.php @@ -7,7 +7,6 @@ namespace Drupal\system\Tests\Mail; -use Drupal\Core\Language\Language; use Drupal\simpletest\WebTestBase; /** @@ -67,7 +66,7 @@ public function testCancelMessage() { \Drupal::state()->set('system.test_mail_collector', array()); // Send a test message that simpletest_mail_alter should cancel. - drupal_mail('simpletest', 'cancel_test', 'cancel@example.com', $language_interface->id); + drupal_mail('simpletest', 'cancel_test', 'cancel@example.com', $language_interface->getId()); // Retrieve sent message. $captured_emails = \Drupal::state()->get('system.test_mail_collector'); $sent_message = end($captured_emails); diff --git a/core/modules/system/lib/Drupal/system/Tests/Path/AliasTest.php b/core/modules/system/lib/Drupal/system/Tests/Path/AliasTest.php index 0baae45..0c1b49b 100644 --- a/core/modules/system/lib/Drupal/system/Tests/Path/AliasTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/Path/AliasTest.php @@ -154,7 +154,7 @@ function testLookupPath() { $aliasStorage->save('user/2', 'bar'); // Hook that clears cache is not executed with unit tests. $aliasManager->cacheClear(); - $this->assertEqual($aliasManager->getPathByAlias('bar'), 'user/2', 'Newer alias record is returned when comparing two Language::LANGCODE_NOT_SPECIFIED paths with the same alias.'); + $this->assertEqual($aliasManager->getPathByAlias('bar'), 'user/2', 'Newer alias record is returned when comparing two LanguageInterface::LANGCODE_NOT_SPECIFIED paths with the same alias.'); } /** diff --git a/core/modules/system/lib/Drupal/system/Tests/System/DateTimeTest.php b/core/modules/system/lib/Drupal/system/Tests/System/DateTimeTest.php index 8f69047..cdb7ead 100644 --- a/core/modules/system/lib/Drupal/system/Tests/System/DateTimeTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/System/DateTimeTest.php @@ -8,7 +8,6 @@ namespace Drupal\system\Tests\System; use Drupal\simpletest\WebTestBase; -use Drupal\Core\Language\Language; /** * Tests generic date and time handling capabilities of Drupal. diff --git a/core/modules/system/lib/Drupal/system/Tests/System/TokenReplaceUnitTest.php b/core/modules/system/lib/Drupal/system/Tests/System/TokenReplaceUnitTest.php index 623d995..fefc8d7 100644 --- a/core/modules/system/lib/Drupal/system/Tests/System/TokenReplaceUnitTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/System/TokenReplaceUnitTest.php @@ -45,7 +45,7 @@ public function testSystemTokenRecognition() { foreach ($tests as $test) { $input = $test['prefix'] . '[site:name]' . $test['suffix']; $expected = $test['prefix'] . 'Drupal' . $test['suffix']; - $output = $this->tokenService->replace($input, array(), array('langcode' => $this->languageInterface->id)); + $output = $this->tokenService->replace($input, array(), array('langcode' => $this->languageInterface->getId())); $this->assertTrue($output == $expected, format_string('Token recognized in string %string', array('%string' => $input))); } @@ -66,12 +66,12 @@ public function testClear() { // Replace with with the clear parameter, only the valid token should remain. $target = String::checkPlain(\Drupal::config('system.site')->get('name')); - $result = $this->tokenService->replace($source, array(), array('langcode' => $this->languageInterface->id, 'clear' => TRUE)); + $result = $this->tokenService->replace($source, array(), array('langcode' => $this->languageInterface->getId(), 'clear' => TRUE)); $this->assertEqual($target, $result, 'Valid tokens replaced while invalid tokens ignored.'); $target .= '[user:name]'; $target .= '[bogus:token]'; - $result = $this->tokenService->replace($source, array(), array('langcode' => $this->languageInterface->id)); + $result = $this->tokenService->replace($source, array(), array('langcode' => $this->languageInterface->getId())); $this->assertEqual($target, $result, 'Valid tokens replaced while invalid tokens ignored.'); } @@ -111,7 +111,7 @@ public function testSystemSiteTokenReplacement() { $this->assertFalse(in_array(0, array_map('strlen', $tests)), 'No empty tokens generated.'); foreach ($tests as $input => $expected) { - $output = $this->tokenService->replace($input, array(), array('langcode' => $this->languageInterface->id)); + $output = $this->tokenService->replace($input, array(), array('langcode' => $this->languageInterface->getId())); $this->assertEqual($output, $expected, format_string('Sanitized system site information token %token replaced.', array('%token' => $input))); } @@ -120,7 +120,7 @@ public function testSystemSiteTokenReplacement() { $tests['[site:slogan]'] = $config->get('slogan'); foreach ($tests as $input => $expected) { - $output = $this->tokenService->replace($input, array(), array('langcode' => $this->languageInterface->id, 'sanitize' => FALSE)); + $output = $this->tokenService->replace($input, array(), array('langcode' => $this->languageInterface->getId(), 'sanitize' => FALSE)); $this->assertEqual($output, $expected, format_string('Unsanitized system site information token %token replaced.', array('%token' => $input))); } @@ -146,18 +146,18 @@ public function testSystemDateTokenReplacement() { // Generate and test tokens. $tests = array(); $date_service = \Drupal::service('date'); - $tests['[date:short]'] = $date_service->format($date, 'short', '', NULL, $this->languageInterface->id); - $tests['[date:medium]'] = $date_service->format($date, 'medium', '', NULL, $this->languageInterface->id); - $tests['[date:long]'] = $date_service->format($date, 'long', '', NULL, $this->languageInterface->id); - $tests['[date:custom:m/j/Y]'] = $date_service->format($date, 'custom', 'm/j/Y', NULL, $this->languageInterface->id); - $tests['[date:since]'] = $date_service->formatInterval(REQUEST_TIME - $date, 2, $this->languageInterface->id); + $tests['[date:short]'] = $date_service->format($date, 'short', '', NULL, $this->languageInterface->getId()); + $tests['[date:medium]'] = $date_service->format($date, 'medium', '', NULL, $this->languageInterface->getId()); + $tests['[date:long]'] = $date_service->format($date, 'long', '', NULL, $this->languageInterface->getId()); + $tests['[date:custom:m/j/Y]'] = $date_service->format($date, 'custom', 'm/j/Y', NULL, $this->languageInterface->getId()); + $tests['[date:since]'] = $date_service->formatInterval(REQUEST_TIME - $date, 2, $this->languageInterface->getId()); $tests['[date:raw]'] = Xss::filter($date); // Test to make sure that we generated something for each token. $this->assertFalse(in_array(0, array_map('strlen', $tests)), 'No empty tokens generated.'); foreach ($tests as $input => $expected) { - $output = $this->tokenService->replace($input, array('date' => $date), array('langcode' => $this->languageInterface->id)); + $output = $this->tokenService->replace($input, array('date' => $date), array('langcode' => $this->languageInterface->getId())); $this->assertEqual($output, $expected, format_string('Date token %token replaced.', array('%token' => $input))); } } diff --git a/core/modules/system/lib/Drupal/system/Tests/System/TokenReplaceUnitTestBase.php b/core/modules/system/lib/Drupal/system/Tests/System/TokenReplaceUnitTestBase.php index c13bd4c..14602ad 100644 --- a/core/modules/system/lib/Drupal/system/Tests/System/TokenReplaceUnitTestBase.php +++ b/core/modules/system/lib/Drupal/system/Tests/System/TokenReplaceUnitTestBase.php @@ -7,7 +7,6 @@ namespace Drupal\system\Tests\System; -use Drupal\Core\Language\Language; use Drupal\system\Tests\Entity\EntityUnitTestBase; /** diff --git a/core/modules/system/lib/Drupal/system/Tests/Theme/TwigTransTest.php b/core/modules/system/lib/Drupal/system/Tests/Theme/TwigTransTest.php index 47d4557..7e8f3c6 100644 --- a/core/modules/system/lib/Drupal/system/Tests/Theme/TwigTransTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/Theme/TwigTransTest.php @@ -81,12 +81,12 @@ protected function setUp() { // Assign Lolspeak (xx) to be the default language. $language = \Drupal::languageManager()->getLanguage('xx'); - $language->default = TRUE; + $language->setDefault(TRUE); language_save($language); $this->rebuildContainer(); // Check that lolspeak is the default language for the site. - $this->assertEqual(\Drupal::languageManager()->getDefaultLanguage()->id, 'xx', 'Lolspeak is the default language'); + $this->assertEqual(\Drupal::languageManager()->getDefaultLanguage()->getId(), 'xx', 'Lolspeak is the default language'); } /** diff --git a/core/modules/system/system.api.php b/core/modules/system/system.api.php index c69838a..4011b9f 100644 --- a/core/modules/system/system.api.php +++ b/core/modules/system/system.api.php @@ -307,7 +307,7 @@ function hook_library_alter(array &$library, $name) { $language_interface = \Drupal::languageManager()->getCurrentLanguage(); $settings['jquery']['ui']['datepicker'] = array( - 'isRTL' => $language_interface->direction == Language::DIRECTION_RTL, + 'isRTL' => $language_interface->getDirection() == LanguageInterface::DIRECTION_RTL, 'firstDay' => \Drupal::config('system.date')->get('first_day'), ); $library['js'][] = array( @@ -1265,7 +1265,7 @@ function hook_watchdog(array $log_entry) { '@message' => strip_tags($log_entry['message']), )); - drupal_mail('emaillog', 'entry', $to, $language_interface->id, $params); + drupal_mail('emaillog', 'entry', $to, $language_interface->getId(), $params); } /** diff --git a/core/modules/system/system.install b/core/modules/system/system.install index a14cd7b..74dbb8c 100644 --- a/core/modules/system/system.install +++ b/core/modules/system/system.install @@ -7,7 +7,6 @@ use Drupal\Component\Utility\Crypt; use Drupal\Core\Database\Database; -use Drupal\Core\Language\Language; use Drupal\Core\Site\Settings; use Drupal\Core\StreamWrapper\PublicStream; diff --git a/core/modules/system/system.module b/core/modules/system/system.module index 8feb47b..aad2230 100644 --- a/core/modules/system/system.module +++ b/core/modules/system/system.module @@ -6,7 +6,7 @@ */ use Drupal\Core\Cache\Cache; -use Drupal\Core\Language\Language; +use Drupal\Core\Language\LanguageInterface; use Drupal\Core\Extension\Extension; use Drupal\Core\Extension\ExtensionDiscovery; use Drupal\block\BlockPluginInterface; @@ -513,7 +513,7 @@ function system_element_info() { ); $types['language_select'] = array( '#input' => TRUE, - '#default_value' => Language::LANGCODE_NOT_SPECIFIED, + '#default_value' => LanguageInterface::LANGCODE_NOT_SPECIFIED, ); $types['weight'] = array( '#input' => TRUE, @@ -973,7 +973,7 @@ function system_page_build(&$page) { array( 'path' => current_path(), 'front' => drupal_is_front_page(), - 'language' => \Drupal::languageManager()->getCurrentLanguage(\Drupal\Core\Language\Language::TYPE_URL)->id, + 'language' => \Drupal::languageManager()->getCurrentLanguage(\Drupal\Core\Language\LanguageInterface::TYPE_URL)->getId(), 'query' => \Drupal::service('request')->query->all(), ) ); diff --git a/core/modules/system/tests/modules/entity_test/entity_test.module b/core/modules/system/tests/modules/entity_test/entity_test.module index 9bc9682..2777dd9 100644 --- a/core/modules/system/tests/modules/entity_test/entity_test.module +++ b/core/modules/system/tests/modules/entity_test/entity_test.module @@ -392,28 +392,28 @@ function entity_test_entity_operation_alter(array &$operations, EntityInterface * Implements hook_entity_translation_insert(). */ function entity_test_entity_translation_insert(EntityInterface $translation) { - _entity_test_record_hooks('entity_translation_insert', $translation->language()->id); + _entity_test_record_hooks('entity_translation_insert', $translation->language()->getId()); } /** * Implements hook_entity_translation_delete(). */ function entity_test_entity_translation_delete(EntityInterface $translation) { - _entity_test_record_hooks('entity_translation_delete', $translation->language()->id); + _entity_test_record_hooks('entity_translation_delete', $translation->language()->getId()); } /** * Implements hook_ENTITY_TYPE_translation_insert(). */ function entity_test_entity_test_mul_translation_insert(EntityInterface $translation) { - _entity_test_record_hooks('entity_test_mul_translation_insert', $translation->language()->id); + _entity_test_record_hooks('entity_test_mul_translation_insert', $translation->language()->getId()); } /** * Implements hook_ENTITY_TYPE_translation_delete(). */ function entity_test_entity_test_mul_translation_delete(EntityInterface $translation) { - _entity_test_record_hooks('entity_test_mul_translation_delete', $translation->language()->id); + _entity_test_record_hooks('entity_test_mul_translation_delete', $translation->language()->getId()); } /** diff --git a/core/modules/system/tests/modules/entity_test/lib/Drupal/entity_test/EntityTestAccessController.php b/core/modules/system/tests/modules/entity_test/lib/Drupal/entity_test/EntityTestAccessController.php index 034caa3..5f23487 100644 --- a/core/modules/system/tests/modules/entity_test/lib/Drupal/entity_test/EntityTestAccessController.php +++ b/core/modules/system/tests/modules/entity_test/lib/Drupal/entity_test/EntityTestAccessController.php @@ -9,7 +9,7 @@ use Drupal\Core\Entity\EntityInterface; use Drupal\Core\Entity\EntityAccessController; -use Drupal\Core\Language\Language; +use Drupal\Core\Language\LanguageInterface; use Drupal\Core\Session\AccountInterface; /** @@ -22,7 +22,7 @@ class EntityTestAccessController extends EntityAccessController { */ protected function checkAccess(EntityInterface $entity, $operation, $langcode, AccountInterface $account) { if ($operation === 'view') { - if ($langcode != Language::LANGCODE_DEFAULT) { + if ($langcode != LanguageInterface::LANGCODE_DEFAULT) { return user_access('view test entity translations', $account); } return user_access('view test entity', $account); diff --git a/core/modules/system/tests/modules/entity_test/lib/Drupal/entity_test/EntityTestForm.php b/core/modules/system/tests/modules/entity_test/lib/Drupal/entity_test/EntityTestForm.php index 849ea17..5aa5bde 100644 --- a/core/modules/system/tests/modules/entity_test/lib/Drupal/entity_test/EntityTestForm.php +++ b/core/modules/system/tests/modules/entity_test/lib/Drupal/entity_test/EntityTestForm.php @@ -7,7 +7,7 @@ namespace Drupal\entity_test; use Drupal\Core\Entity\ContentEntityForm; -use Drupal\Core\Language\Language; +use Drupal\Core\Language\LanguageInterface; /** * Form controller for the test entity edit forms. @@ -44,8 +44,8 @@ public function form(array $form, array &$form_state) { $form['langcode'] = array( '#title' => t('Language'), '#type' => 'language_select', - '#default_value' => $entity->getUntranslated()->language()->id, - '#languages' => Language::STATE_ALL, + '#default_value' => $entity->getUntranslated()->language()->getId(), + '#languages' => LanguageInterface::STATE_ALL, ); // @todo: Is there a better way to check if an entity type is revisionable? diff --git a/core/modules/system/tests/modules/form_test/form_test.module b/core/modules/system/tests/modules/form_test/form_test.module index 42ef667..38f5176 100644 --- a/core/modules/system/tests/modules/form_test/form_test.module +++ b/core/modules/system/tests/modules/form_test/form_test.module @@ -7,7 +7,7 @@ use Drupal\Component\Serialization\Json; use Drupal\Core\Database\Database; -use Drupal\Core\Language\Language; +use Drupal\Core\Language\LanguageInterface; use Drupal\form_test\Callbacks; use Drupal\Core\Datetime\DrupalDateTime; use Symfony\Component\HttpFoundation\JsonResponse; @@ -1000,30 +1000,30 @@ function form_test_language_select() { $form['languages_all'] = array( '#title' => t('Languages: All'), '#type' => 'language_select', - '#languages' => Language::STATE_ALL, + '#languages' => LanguageInterface::STATE_ALL, '#default_value' => 'xx', ); $form['languages_configurable'] = array( '#title' => t('Languages: Configurable'), '#type' => 'language_select', - '#languages' => Language::STATE_CONFIGURABLE, + '#languages' => LanguageInterface::STATE_CONFIGURABLE, '#default_value' => 'en', ); $form['languages_locked'] = array( '#title' => t('Languages: Locked'), '#type' => 'language_select', - '#languages' => Language::STATE_LOCKED, + '#languages' => LanguageInterface::STATE_LOCKED, ); $form['languages_config_and_locked'] = array( '#title' => t('Languages: Configurable and locked'), '#type' => 'language_select', - '#languages' => Language::STATE_CONFIGURABLE | Language::STATE_LOCKED, + '#languages' => LanguageInterface::STATE_CONFIGURABLE | LanguageInterface::STATE_LOCKED, '#default_value' => 'dummy_value', ); $form['language_custom_options'] = array( '#title' => t('Languages: Custom'), '#type' => 'language_select', - '#languages' => Language::STATE_CONFIGURABLE | Language::STATE_LOCKED, + '#languages' => LanguageInterface::STATE_CONFIGURABLE | LanguageInterface::STATE_LOCKED, '#options' => array('opt1' => 'First option', 'opt2' => 'Second option', 'opt3' => 'Third option'), '#default_value' => 'opt2', ); diff --git a/core/modules/system/tests/modules/form_test/lib/Drupal/form_test/Controller/FormTestController.php b/core/modules/system/tests/modules/form_test/lib/Drupal/form_test/Controller/FormTestController.php index ad96815..600b1d9 100644 --- a/core/modules/system/tests/modules/form_test/lib/Drupal/form_test/Controller/FormTestController.php +++ b/core/modules/system/tests/modules/form_test/lib/Drupal/form_test/Controller/FormTestController.php @@ -7,7 +7,7 @@ namespace Drupal\form_test\Controller; use Drupal\Core\Controller\ControllerBase; -use Drupal\Core\Language\Language; +use Drupal\Core\Language\LanguageInterface; /** * Controller routines for form_test routes. @@ -26,7 +26,7 @@ public function twoFormInstances() { 'uid' => $user->id(), 'name' => $user->getUsername(), 'type' => 'page', - 'langcode' => Language::LANGCODE_NOT_SPECIFIED, + 'langcode' => LanguageInterface::LANGCODE_NOT_SPECIFIED, ); $node1 = $this->entityManager()->getStorage('node')->create($values); $node2 = clone($node1); diff --git a/core/modules/system/tests/modules/plugin_test/lib/Drupal/plugin_test/Plugin/CachedMockBlockManager.php b/core/modules/system/tests/modules/plugin_test/lib/Drupal/plugin_test/Plugin/CachedMockBlockManager.php index df79b31..b1bb1d8 100644 --- a/core/modules/system/tests/modules/plugin_test/lib/Drupal/plugin_test/Plugin/CachedMockBlockManager.php +++ b/core/modules/system/tests/modules/plugin_test/lib/Drupal/plugin_test/Plugin/CachedMockBlockManager.php @@ -7,7 +7,6 @@ namespace Drupal\plugin_test\Plugin; -use Drupal\Core\Language\Language; use Drupal\Core\Plugin\Discovery\CacheDecorator; /** @@ -25,6 +24,6 @@ public function __construct() { // The CacheDecorator allows us to cache these plugin definitions for // quicker retrieval. In this case we are generating a cache key by // language. - $this->discovery = new CacheDecorator($this->discovery, 'mock_block:' . \Drupal::languageManager()->getCurrentLanguage()->id, 'default', 1542646800, array('plugin_test')); + $this->discovery = new CacheDecorator($this->discovery, 'mock_block:' . \Drupal::languageManager()->getCurrentLanguage()->getId(), 'default', 1542646800, array('plugin_test')); } } diff --git a/core/modules/system/tests/upgrade/drupal-7.language.database.php b/core/modules/system/tests/upgrade/drupal-7.language.database.php index 8025354..95b80d2 100644 --- a/core/modules/system/tests/upgrade/drupal-7.language.database.php +++ b/core/modules/system/tests/upgrade/drupal-7.language.database.php @@ -422,7 +422,7 @@ // Add sample nodes to test language assignment and translation functionality. // The first node is also used for testing comment language functionality. This -// is a simple node with Language::LANGCODE_NOT_SPECIFIED as language code. The second +// is a simple node with LanguageInterface::LANGCODE_NOT_SPECIFIED as language code. The second // node is a Catalan node (language code 'ca'). The third and fourth node are a // translation set with an English source translation (language code 'en') and // a Chuvash translation (language code 'cv'). @@ -545,7 +545,7 @@ 'vid' => '70', 'uid' => '6', 'title' => 'Node title 50', - 'log' => 'Added a Language::LANGCODE_NOT_SPECIFIED node to comment on.', + 'log' => 'Added a LanguageInterface::LANGCODE_NOT_SPECIFIED node to comment on.', 'timestamp' => '1314997642', 'status' => '1', 'comment' => '2', diff --git a/core/modules/system/theme.api.php b/core/modules/system/theme.api.php index 50fa74e..8d121f6 100644 --- a/core/modules/system/theme.api.php +++ b/core/modules/system/theme.api.php @@ -288,7 +288,7 @@ function hook_theme_suggestions_HOOK(array $variables) { */ function hook_theme_suggestions_alter(array &$suggestions, array $variables, $hook) { // Add an interface-language specific suggestion to all theme hooks. - $suggestions[] = $hook . '__' . \Drupal::languageManager()->getCurrentLanguage()->id; + $suggestions[] = $hook . '__' . \Drupal::languageManager()->getCurrentLanguage()->getId(); } /** diff --git a/core/modules/taxonomy/lib/Drupal/taxonomy/Entity/Term.php b/core/modules/taxonomy/lib/Drupal/taxonomy/Entity/Term.php index 510524a..4e1f1f8 100644 --- a/core/modules/taxonomy/lib/Drupal/taxonomy/Entity/Term.php +++ b/core/modules/taxonomy/lib/Drupal/taxonomy/Entity/Term.php @@ -11,7 +11,6 @@ use Drupal\Core\Entity\EntityStorageInterface; use Drupal\Core\Entity\EntityTypeInterface; use Drupal\Core\Field\FieldDefinition; -use Drupal\Core\Language\Language; use Drupal\Core\TypedData\DataDefinition; use Drupal\taxonomy\TermInterface; diff --git a/core/modules/taxonomy/lib/Drupal/taxonomy/Plugin/views/field/Language.php b/core/modules/taxonomy/lib/Drupal/taxonomy/Plugin/views/field/Language.php index 13e3d23..6345f5b 100644 --- a/core/modules/taxonomy/lib/Drupal/taxonomy/Plugin/views/field/Language.php +++ b/core/modules/taxonomy/lib/Drupal/taxonomy/Plugin/views/field/Language.php @@ -22,7 +22,7 @@ class Language extends Taxonomy { public function render(ResultRow $values) { $value = $this->getValue($values); $language = language_load($value); - $value = $language ? $language->name : ''; + $value = $language ? $language->getName() : ''; return $this->renderLink($this->sanitizeValue($value), $values); } diff --git a/core/modules/taxonomy/lib/Drupal/taxonomy/TermForm.php b/core/modules/taxonomy/lib/Drupal/taxonomy/TermForm.php index e3b048a..cfef112 100644 --- a/core/modules/taxonomy/lib/Drupal/taxonomy/TermForm.php +++ b/core/modules/taxonomy/lib/Drupal/taxonomy/TermForm.php @@ -9,7 +9,7 @@ use Drupal\Core\Cache\Cache; use Drupal\Core\Entity\ContentEntityForm; -use Drupal\Core\Language\Language; +use Drupal\Core\Language\LanguageInterface; /** * Base for controller for taxonomy term edit forms. @@ -32,8 +32,8 @@ public function form(array $form, array &$form_state) { $form['langcode'] = array( '#type' => 'language_select', '#title' => $this->t('Language'), - '#languages' => Language::STATE_ALL, - '#default_value' => $term->getUntranslated()->language()->id, + '#languages' => LanguageInterface::STATE_ALL, + '#default_value' => $term->getUntranslated()->language()->getId(), '#access' => !empty($language_configuration['language_show']), ); diff --git a/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/TaxonomyTermReferenceItemTest.php b/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/TaxonomyTermReferenceItemTest.php index 0a67140..61be0d0 100644 --- a/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/TaxonomyTermReferenceItemTest.php +++ b/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/TaxonomyTermReferenceItemTest.php @@ -10,7 +10,7 @@ use Drupal\Core\Field\FieldDefinitionInterface; use Drupal\Core\Field\FieldItemListInterface; use Drupal\Core\Field\FieldItemInterface; -use Drupal\Core\Language\Language; +use Drupal\Core\Language\LanguageInterface; use Drupal\field\Tests\FieldUnitTestBase; /** @@ -48,7 +48,7 @@ public function setUp() { $vocabulary = entity_create('taxonomy_vocabulary', array( 'name' => $this->randomName(), 'vid' => drupal_strtolower($this->randomName()), - 'langcode' => Language::LANGCODE_NOT_SPECIFIED, + 'langcode' => LanguageInterface::LANGCODE_NOT_SPECIFIED, )); $vocabulary->save(); @@ -74,7 +74,7 @@ public function setUp() { $this->term = entity_create('taxonomy_term', array( 'name' => $this->randomName(), 'vid' => $vocabulary->id(), - 'langcode' => Language::LANGCODE_NOT_SPECIFIED, + 'langcode' => LanguageInterface::LANGCODE_NOT_SPECIFIED, )); $this->term->save(); } @@ -110,7 +110,7 @@ public function testTaxonomyTermReferenceItem() { $term2 = entity_create('taxonomy_term', array( 'name' => $this->randomName(), 'vid' => $this->term->getVocabularyId(), - 'langcode' => Language::LANGCODE_NOT_SPECIFIED, + 'langcode' => LanguageInterface::LANGCODE_NOT_SPECIFIED, )); $term2->save(); diff --git a/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/TaxonomyTestBase.php b/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/TaxonomyTestBase.php index 9fd5a34..3840c65 100644 --- a/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/TaxonomyTestBase.php +++ b/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/TaxonomyTestBase.php @@ -7,7 +7,7 @@ namespace Drupal\taxonomy\Tests; -use Drupal\Core\Language\Language; +use Drupal\Core\Language\LanguageInterface; use Drupal\simpletest\WebTestBase; /** @@ -40,7 +40,7 @@ function createVocabulary() { 'name' => $this->randomName(), 'description' => $this->randomName(), 'vid' => drupal_strtolower($this->randomName()), - 'langcode' => Language::LANGCODE_NOT_SPECIFIED, + 'langcode' => LanguageInterface::LANGCODE_NOT_SPECIFIED, 'weight' => mt_rand(0, 10), )); $vocabulary->save(); @@ -61,7 +61,7 @@ function createTerm($vocabulary) { 'format' => $format->format, ), 'vid' => $vocabulary->id(), - 'langcode' => Language::LANGCODE_NOT_SPECIFIED, + 'langcode' => LanguageInterface::LANGCODE_NOT_SPECIFIED, )); $term->save(); return $term; diff --git a/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/TermLanguageTest.php b/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/TermLanguageTest.php index 256a0a0..3da8b1b 100644 --- a/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/TermLanguageTest.php +++ b/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/TermLanguageTest.php @@ -63,7 +63,7 @@ function testTermLanguage() { $this->drupalPostForm(NULL, $edit, t('Save')); $terms = taxonomy_term_load_multiple_by_name($edit['name[0][value]']); $term = reset($terms); - $this->assertEqual($term->language()->id, $edit['langcode'], 'The term contains the correct langcode.'); + $this->assertEqual($term->language()->getId(), $edit['langcode'], 'The term contains the correct langcode.'); // Check if on the edit page the language is correct. $this->drupalGet('taxonomy/term/' . $term->id() . '/edit'); @@ -103,10 +103,10 @@ function testDefaultTermLanguage() { // Change the default language of the site and check if the default terms // language is still correctly selected. $old_default = \Drupal::languageManager()->getDefaultLanguage(); - $old_default->default = FALSE; + $old_default->setDefault(FALSE); language_save($old_default); $new_default = \Drupal::languageManager()->getLanguage('cc'); - $new_default->default = TRUE; + $new_default->setDefault(TRUE); language_save($new_default); $edit = array( 'default_language[langcode]' => 'site_default', diff --git a/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/TermTranslationUITest.php b/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/TermTranslationUITest.php index a027ade..73033d5 100644 --- a/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/TermTranslationUITest.php +++ b/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/TermTranslationUITest.php @@ -7,7 +7,7 @@ namespace Drupal\taxonomy\Tests; -use Drupal\Core\Language\Language; +use Drupal\Core\Language\LanguageInterface; use Drupal\content_translation\Tests\ContentTranslationUITest; /** @@ -60,7 +60,7 @@ protected function setupBundle() { 'name' => $this->bundle, 'description' => $this->randomName(), 'vid' => $this->bundle, - 'langcode' => Language::LANGCODE_NOT_SPECIFIED, + 'langcode' => LanguageInterface::LANGCODE_NOT_SPECIFIED, 'weight' => mt_rand(0, 10), )); $this->vocabulary->save(); @@ -128,7 +128,7 @@ function testTranslateLinkVocabularyAdminPage() { 'name' => 'untranslatable_voc', 'description' => $this->randomName(), 'vid' => 'untranslatable_voc', - 'langcode' => Language::LANGCODE_NOT_SPECIFIED, + 'langcode' => LanguageInterface::LANGCODE_NOT_SPECIFIED, 'weight' => mt_rand(0, 10), )); $untranslatable_vocabulary->save(); diff --git a/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/TokenReplaceTest.php b/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/TokenReplaceTest.php index a09cbc2..f2e72f41 100644 --- a/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/TokenReplaceTest.php +++ b/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/TokenReplaceTest.php @@ -9,7 +9,6 @@ use Drupal\Component\Utility\Xss; use Drupal\Core\Field\FieldDefinitionInterface; -use Drupal\Core\Language\Language; use Drupal\Component\Utility\String; /** @@ -97,7 +96,7 @@ function testTaxonomyTokenReplacement() { $tests['[term:vocabulary:name]'] = String::checkPlain($this->vocabulary->name); foreach ($tests as $input => $expected) { - $output = $token_service->replace($input, array('term' => $term1), array('langcode' => $language_interface->id)); + $output = $token_service->replace($input, array('term' => $term1), array('langcode' => $language_interface->getId())); $this->assertEqual($output, $expected, format_string('Sanitized taxonomy term token %token replaced.', array('%token' => $input))); } @@ -117,7 +116,7 @@ function testTaxonomyTokenReplacement() { $this->assertFalse(in_array(0, array_map('strlen', $tests)), 'No empty tokens generated.'); foreach ($tests as $input => $expected) { - $output = $token_service->replace($input, array('term' => $term2), array('langcode' => $language_interface->id)); + $output = $token_service->replace($input, array('term' => $term2), array('langcode' => $language_interface->getId())); $this->assertEqual($output, $expected, format_string('Sanitized taxonomy term token %token replaced.', array('%token' => $input))); } @@ -128,7 +127,7 @@ function testTaxonomyTokenReplacement() { $tests['[term:vocabulary:name]'] = $this->vocabulary->name; foreach ($tests as $input => $expected) { - $output = $token_service->replace($input, array('term' => $term2), array('langcode' => $language_interface->id, 'sanitize' => FALSE)); + $output = $token_service->replace($input, array('term' => $term2), array('langcode' => $language_interface->getId(), 'sanitize' => FALSE)); $this->assertEqual($output, $expected, format_string('Unsanitized taxonomy term token %token replaced.', array('%token' => $input))); } @@ -144,7 +143,7 @@ function testTaxonomyTokenReplacement() { $this->assertFalse(in_array(0, array_map('strlen', $tests)), 'No empty tokens generated.'); foreach ($tests as $input => $expected) { - $output = $token_service->replace($input, array('vocabulary' => $this->vocabulary), array('langcode' => $language_interface->id)); + $output = $token_service->replace($input, array('vocabulary' => $this->vocabulary), array('langcode' => $language_interface->getId())); $this->assertEqual($output, $expected, format_string('Sanitized taxonomy vocabulary token %token replaced.', array('%token' => $input))); } @@ -153,7 +152,7 @@ function testTaxonomyTokenReplacement() { $tests['[vocabulary:description]'] = $this->vocabulary->description; foreach ($tests as $input => $expected) { - $output = $token_service->replace($input, array('vocabulary' => $this->vocabulary), array('langcode' => $language_interface->id, 'sanitize' => FALSE)); + $output = $token_service->replace($input, array('vocabulary' => $this->vocabulary), array('langcode' => $language_interface->getId(), 'sanitize' => FALSE)); $this->assertEqual($output, $expected, format_string('Unsanitized taxonomy vocabulary token %token replaced.', array('%token' => $input))); } } diff --git a/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/Views/TaxonomyTestBase.php b/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/Views/TaxonomyTestBase.php index 2cc992e..587f4ce 100644 --- a/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/Views/TaxonomyTestBase.php +++ b/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/Views/TaxonomyTestBase.php @@ -8,7 +8,7 @@ namespace Drupal\taxonomy\Tests\Views; use Drupal\Core\Field\FieldDefinitionInterface; -use Drupal\Core\Language\Language; +use Drupal\Core\Language\LanguageInterface; use Drupal\views\Tests\ViewTestBase; use Drupal\views\Tests\ViewTestData; @@ -136,7 +136,7 @@ protected function createTerm() { // Use the first available text format. 'format' => $format->format, 'vid' => $this->vocabulary->id(), - 'langcode' => Language::LANGCODE_NOT_SPECIFIED, + 'langcode' => LanguageInterface::LANGCODE_NOT_SPECIFIED, )); $term->save(); return $term; diff --git a/core/modules/taxonomy/lib/Drupal/taxonomy/VocabularyForm.php b/core/modules/taxonomy/lib/Drupal/taxonomy/VocabularyForm.php index 341bcbe..7287055 100644 --- a/core/modules/taxonomy/lib/Drupal/taxonomy/VocabularyForm.php +++ b/core/modules/taxonomy/lib/Drupal/taxonomy/VocabularyForm.php @@ -9,7 +9,7 @@ use Drupal\Core\Entity\EntityForm; use Drupal\Core\Entity\EntityTypeInterface; -use Drupal\Core\Language\Language; +use Drupal\Core\Language\LanguageInterface; /** * Base form for vocabulary edit forms. @@ -57,7 +57,7 @@ public function form(array $form, array &$form_state) { $form['langcode'] = array( '#type' => 'language_select', '#title' => $this->t('Vocabulary language'), - '#languages' => Language::STATE_ALL, + '#languages' => LanguageInterface::STATE_ALL, '#default_value' => $vocabulary->langcode, ); if ($this->moduleHandler->moduleExists('language')) { diff --git a/core/modules/taxonomy/taxonomy.module b/core/modules/taxonomy/taxonomy.module index 4577e7e..b365c52 100644 --- a/core/modules/taxonomy/taxonomy.module +++ b/core/modules/taxonomy/taxonomy.module @@ -781,7 +781,7 @@ function taxonomy_build_node_index($node) { $field_name = $field->getName(); if ($field->getType() == 'taxonomy_term_reference') { foreach ($node->getTranslationLanguages() as $language) { - foreach ($node->getTranslation($language->id)->$field_name as $item) { + foreach ($node->getTranslation($language->getId())->$field_name as $item) { if (!$item->isEmpty()) { $tid_all[$item->target_id] = $item->target_id; } diff --git a/core/modules/text/lib/Drupal/text/Tests/Formatter/TextPlainUnitTest.php b/core/modules/text/lib/Drupal/text/Tests/Formatter/TextPlainUnitTest.php index 8e37920..507874c 100644 --- a/core/modules/text/lib/Drupal/text/Tests/Formatter/TextPlainUnitTest.php +++ b/core/modules/text/lib/Drupal/text/Tests/Formatter/TextPlainUnitTest.php @@ -9,7 +9,7 @@ use Drupal\Core\Entity\ContentEntityInterface; use Drupal\Core\Entity\Display\EntityViewDisplayInterface; -use Drupal\Core\Language\Language; +use Drupal\Core\Language\LanguageInterface; use Drupal\simpletest\DrupalUnitTestBase; /** @@ -92,7 +92,7 @@ function setUp() { )); $this->display->save(); - $this->langcode = Language::LANGCODE_NOT_SPECIFIED; + $this->langcode = LanguageInterface::LANGCODE_NOT_SPECIFIED; } /** diff --git a/core/modules/text/lib/Drupal/text/Tests/TextWithSummaryItemTest.php b/core/modules/text/lib/Drupal/text/Tests/TextWithSummaryItemTest.php index 9b93095..36008fc 100644 --- a/core/modules/text/lib/Drupal/text/Tests/TextWithSummaryItemTest.php +++ b/core/modules/text/lib/Drupal/text/Tests/TextWithSummaryItemTest.php @@ -7,7 +7,7 @@ namespace Drupal\text\Tests; -use Drupal\Core\Language\Language; +use Drupal\Core\Language\LanguageInterface; use Drupal\Core\Field\FieldItemListInterface; use Drupal\Core\Field\FieldItemInterface; use Drupal\field\Tests\FieldUnitTestBase; @@ -128,7 +128,7 @@ function testProcessedCache() { $entity = entity_load($entity_type, $entity->id()); $cache = \Drupal::cache('entity')->get("field:$entity_type:" . $entity->id()); $this->assertEqual($cache->data, array( - Language::LANGCODE_NOT_SPECIFIED => array( + LanguageInterface::LANGCODE_NOT_SPECIFIED => array( 'summary_field' => array( 0 => array( 'value' => $value, @@ -144,7 +144,7 @@ function testProcessedCache() { // Inject fake processed values into the cache to make sure that these are // used as-is and not re-calculated when the entity is loaded. $data = array( - Language::LANGCODE_NOT_SPECIFIED => array( + LanguageInterface::LANGCODE_NOT_SPECIFIED => array( 'summary_field' => array( 0 => array( 'value' => $value, diff --git a/core/modules/toolbar/toolbar.module b/core/modules/toolbar/toolbar.module index 3599c59..d09660e 100644 --- a/core/modules/toolbar/toolbar.module +++ b/core/modules/toolbar/toolbar.module @@ -6,7 +6,6 @@ */ use Drupal\Core\Cache\Cache; -use Drupal\Core\Language\Language; use Drupal\Core\Render\Element; use Drupal\Core\Template\Attribute; use Drupal\Component\Utility\Crypt; @@ -374,7 +373,7 @@ function toolbar_toolbar() { // toolbar_subtrees route. We provide the JavaScript requesting that JSONP // script here with the hash parameter that is needed for that route. // @see toolbar_subtrees_jsonp() - $langcode = \Drupal::languageManager()->getCurrentLanguage()->id; + $langcode = \Drupal::languageManager()->getCurrentLanguage()->getId(); $menu['toolbar_administration']['#attached']['js'][] = array( 'type' => 'setting', 'data' => array('toolbar' => array( diff --git a/core/modules/tracker/lib/Drupal/tracker/Tests/Views/TrackerTestBase.php b/core/modules/tracker/lib/Drupal/tracker/Tests/Views/TrackerTestBase.php index a727ad5..7f20868 100644 --- a/core/modules/tracker/lib/Drupal/tracker/Tests/Views/TrackerTestBase.php +++ b/core/modules/tracker/lib/Drupal/tracker/Tests/Views/TrackerTestBase.php @@ -7,7 +7,7 @@ namespace Drupal\tracker\Tests\Views; -use Drupal\Core\Language\Language; +use Drupal\Core\Language\LanguageInterface; use Drupal\views\Tests\ViewTestBase; use Drupal\views\Tests\ViewTestData; @@ -55,7 +55,7 @@ protected function setUp() { 'entity_type' => 'node', 'field_name' => 'comment', 'subject' => $this->randomName(), - 'comment_body[' . Language::LANGCODE_NOT_SPECIFIED . '][0][value]' => $this->randomName(20), + 'comment_body[' . LanguageInterface::LANGCODE_NOT_SPECIFIED . '][0][value]' => $this->randomName(20), )); } diff --git a/core/modules/update/update.fetch.inc b/core/modules/update/update.fetch.inc index d456801..1d3340c 100644 --- a/core/modules/update/update.fetch.inc +++ b/core/modules/update/update.fetch.inc @@ -110,7 +110,7 @@ function _update_cron_notify() { if (!empty($params)) { $notify_list = $update_config->get('notification.emails'); if (!empty($notify_list)) { - $default_langcode = \Drupal::languageManager()->getDefaultLanguage()->id; + $default_langcode = \Drupal::languageManager()->getDefaultLanguage()->getId(); foreach ($notify_list as $target) { if ($target_user = user_load_by_mail($target)) { $target_langcode = $target_user->getPreferredLangcode(); diff --git a/core/modules/user/lib/Drupal/user/AccountForm.php b/core/modules/user/lib/Drupal/user/AccountForm.php index 42a2292..646cd86 100644 --- a/core/modules/user/lib/Drupal/user/AccountForm.php +++ b/core/modules/user/lib/Drupal/user/AccountForm.php @@ -10,7 +10,7 @@ use Drupal\Core\Entity\ContentEntityForm; use Drupal\Core\Entity\EntityManagerInterface; use Drupal\Core\Entity\Query\QueryFactory; -use Drupal\Core\Language\Language; +use Drupal\Core\Language\LanguageInterface; use Drupal\Core\Language\LanguageManagerInterface; use Drupal\language\ConfigurableLanguageManagerInterface; use Drupal\user\Plugin\LanguageNegotiation\LanguageNegotiationUserAdmin; @@ -245,15 +245,15 @@ public function form(array $form, array &$form_state) { ); } - $user_preferred_langcode = $register ? $language_interface->id : $account->getPreferredLangcode(); + $user_preferred_langcode = $register ? $language_interface->getId() : $account->getPreferredLangcode(); - $user_preferred_admin_langcode = $register ? $language_interface->id : $account->getPreferredAdminLangcode(); + $user_preferred_admin_langcode = $register ? $language_interface->getId() : $account->getPreferredAdminLangcode(); // Is the user preferred language added? $user_language_added = FALSE; if ($this->languageManager instanceof ConfigurableLanguageManagerInterface) { $negotiator = $this->languageManager->getNegotiator(); - $user_language_added = $negotiator && $negotiator->isNegotiationMethodEnabled(LanguageNegotiationUser::METHOD_ID, Language::TYPE_INTERFACE); + $user_language_added = $negotiator && $negotiator->isNegotiationMethodEnabled(LanguageNegotiationUser::METHOD_ID, LanguageInterface::TYPE_INTERFACE); } $form['language'] = array( '#type' => $this->languageManager->isMultilingual() ? 'details' : 'container', @@ -267,7 +267,7 @@ public function form(array $form, array &$form_state) { $form['language']['preferred_langcode'] = array( '#type' => 'language_select', '#title' => $this->t('Site language'), - '#languages' => Language::STATE_CONFIGURABLE, + '#languages' => LanguageInterface::STATE_CONFIGURABLE, '#default_value' => $user_preferred_langcode, '#description' => $user_language_added ? $this->t("This account's preferred language for e-mails and site presentation.") : $this->t("This account's preferred language for e-mails."), ); @@ -282,7 +282,7 @@ public function form(array $form, array &$form_state) { $form['language']['preferred_admin_langcode'] = array( '#type' => 'language_select', '#title' => $this->t('Administration pages language'), - '#languages' => Language::STATE_CONFIGURABLE, + '#languages' => LanguageInterface::STATE_CONFIGURABLE, '#default_value' => $user_preferred_admin_langcode, '#access' => $show_admin_language, ); diff --git a/core/modules/user/lib/Drupal/user/Entity/User.php b/core/modules/user/lib/Drupal/user/Entity/User.php index 25eb641..ecb45f7 100644 --- a/core/modules/user/lib/Drupal/user/Entity/User.php +++ b/core/modules/user/lib/Drupal/user/Entity/User.php @@ -377,10 +377,10 @@ function getPreferredLangcode($default = NULL) { $language_list = language_list(); $preferred_langcode = $this->get('preferred_langcode')->value; if (!empty($preferred_langcode) && isset($language_list[$preferred_langcode])) { - return $language_list[$preferred_langcode]->id; + return $language_list[$preferred_langcode]->getId(); } else { - return $default ? $default : language_default()->id; + return $default ? $default : language_default()->getId(); } } @@ -391,10 +391,10 @@ function getPreferredAdminLangcode($default = NULL) { $language_list = language_list(); $preferred_langcode = $this->get('preferred_admin_langcode')->value; if (!empty($preferred_langcode) && isset($language_list[$preferred_langcode])) { - return $language_list[$preferred_langcode]->id; + return $language_list[$preferred_langcode]->getId(); } else { - return $default ? $default : language_default()->id; + return $default ? $default : language_default()->getId(); } } diff --git a/core/modules/user/lib/Drupal/user/Form/UserPasswordForm.php b/core/modules/user/lib/Drupal/user/Form/UserPasswordForm.php index 15d48c8..57b7764 100644 --- a/core/modules/user/lib/Drupal/user/Form/UserPasswordForm.php +++ b/core/modules/user/lib/Drupal/user/Form/UserPasswordForm.php @@ -9,7 +9,6 @@ use Drupal\Core\Field\Plugin\Field\FieldType\EmailItem; use Drupal\Core\Form\FormBase; -use Drupal\Core\Language\Language; use Drupal\Core\Language\LanguageManager; use Drupal\user\UserStorageInterface; use Symfony\Component\HttpFoundation\Request; @@ -128,7 +127,7 @@ public function validateForm(array &$form, array &$form_state) { * {@inheritdoc} */ public function submitForm(array &$form, array &$form_state) { - $langcode = $this->languageManager->getCurrentLanguage()->id; + $langcode = $this->languageManager->getCurrentLanguage()->getId(); $account = $form_state['values']['account']; // Mail one time login URL and instructions using current language. diff --git a/core/modules/user/lib/Drupal/user/Plugin/LanguageNegotiation/LanguageNegotiationUser.php b/core/modules/user/lib/Drupal/user/Plugin/LanguageNegotiation/LanguageNegotiationUser.php index f2c99fe..623dac6 100644 --- a/core/modules/user/lib/Drupal/user/Plugin/LanguageNegotiation/LanguageNegotiationUser.php +++ b/core/modules/user/lib/Drupal/user/Plugin/LanguageNegotiation/LanguageNegotiationUser.php @@ -36,7 +36,7 @@ public function getLangcode(Request $request = NULL) { // User preference (only for authenticated users). if ($this->languageManager && $this->currentUser->isAuthenticated()) { $preferred_langcode = $this->currentUser->getPreferredLangcode(); - $default_langcode = $this->languageManager->getDefaultLanguage()->id; + $default_langcode = $this->languageManager->getDefaultLanguage()->getId(); $languages = $this->languageManager->getLanguages(); if (!empty($preferred_langcode) && $preferred_langcode != $default_langcode && isset($languages[$preferred_langcode])) { $langcode = $preferred_langcode; diff --git a/core/modules/user/lib/Drupal/user/Plugin/LanguageNegotiation/LanguageNegotiationUserAdmin.php b/core/modules/user/lib/Drupal/user/Plugin/LanguageNegotiation/LanguageNegotiationUserAdmin.php index 50ed5a9..89fede5 100644 --- a/core/modules/user/lib/Drupal/user/Plugin/LanguageNegotiation/LanguageNegotiationUserAdmin.php +++ b/core/modules/user/lib/Drupal/user/Plugin/LanguageNegotiation/LanguageNegotiationUserAdmin.php @@ -20,7 +20,7 @@ * * @Plugin( * id = Drupal\user\Plugin\LanguageNegotiation\LanguageNegotiationUserAdmin::METHOD_ID, - * types = {Drupal\Core\Language\Language::TYPE_INTERFACE}, + * types = {Drupal\Core\Language\LanguageInterface::TYPE_INTERFACE}, * weight = 10, * name = @Translation("Account administration pages"), * description = @Translation("Account administration pages language setting.") @@ -82,7 +82,7 @@ public function getLangcode(Request $request = NULL) { // User preference (only for authenticated users). if ($this->languageManager && $this->currentUser->isAuthenticated() && $this->isAdminPath($request)) { $preferred_admin_langcode = $this->currentUser->getPreferredAdminLangcode(); - $default_langcode = $this->languageManager->getDefaultLanguage()->id; + $default_langcode = $this->languageManager->getDefaultLanguage()->getId(); $languages = $this->languageManager->getLanguages(); if (!empty($preferred_admin_langcode) && $preferred_admin_langcode != $default_langcode && isset($languages[$preferred_admin_langcode])) { $langcode = $preferred_admin_langcode; diff --git a/core/modules/user/lib/Drupal/user/Tests/UserEntityTest.php b/core/modules/user/lib/Drupal/user/Tests/UserEntityTest.php index 43bee29..9621d33 100644 --- a/core/modules/user/lib/Drupal/user/Tests/UserEntityTest.php +++ b/core/modules/user/lib/Drupal/user/Tests/UserEntityTest.php @@ -7,7 +7,7 @@ namespace Drupal\user\Tests; -use Drupal\Core\Language\Language; +use Drupal\Core\Language\LanguageInterface; use Drupal\simpletest\DrupalUnitTestBase; use Drupal\user\Entity\User; @@ -46,7 +46,7 @@ public function testUserMethods() { $role_storage->create(array('id' => 'test_role_two'))->save(); $role_storage->create(array('id' => 'test_role_three'))->save(); - $values = array('roles' => array(Language::LANGCODE_DEFAULT => array('test_role_one'))); + $values = array('roles' => array(LanguageInterface::LANGCODE_DEFAULT => array('test_role_one'))); $user = new User($values, 'user'); $this->assertTrue($user->hasRole('test_role_one')); diff --git a/core/modules/user/lib/Drupal/user/Tests/UserInstallTest.php b/core/modules/user/lib/Drupal/user/Tests/UserInstallTest.php index 7014a03..3fb16fd 100644 --- a/core/modules/user/lib/Drupal/user/Tests/UserInstallTest.php +++ b/core/modules/user/lib/Drupal/user/Tests/UserInstallTest.php @@ -53,8 +53,8 @@ public function testUserInstall() { // Test that the anonymous and administrators languages are equal to the // site's default language. - $this->assertEqual($anon->langcode, \Drupal::languageManager()->getDefaultLanguage()->id); - $this->assertEqual($admin->langcode, \Drupal::languageManager()->getDefaultLanguage()->id); + $this->assertEqual($anon->langcode, \Drupal::languageManager()->getDefaultLanguage()->getId(), 'Anon user language is the default.'); + $this->assertEqual($admin->langcode, \Drupal::languageManager()->getDefaultLanguage()->getId(), 'Admin user language is the default.'); // Test that the administrator is active. $this->assertEqual($admin->status, 1); diff --git a/core/modules/user/lib/Drupal/user/Tests/UserLanguageCreationTest.php b/core/modules/user/lib/Drupal/user/Tests/UserLanguageCreationTest.php index dbf80e4..2360b7b 100644 --- a/core/modules/user/lib/Drupal/user/Tests/UserLanguageCreationTest.php +++ b/core/modules/user/lib/Drupal/user/Tests/UserLanguageCreationTest.php @@ -69,7 +69,7 @@ function testLocalUserCreation() { $user = user_load_by_name($username); $this->assertEqual($user->getPreferredLangcode(), $langcode, 'New user has correct preferred language set.'); - $this->assertEqual($user->language()->id, $langcode, 'New user has correct profile language set.'); + $this->assertEqual($user->language()->getId(), $langcode, 'New user has correct profile language set.'); // Register a new user and check if the language selector is hidden. $this->drupalLogout(); @@ -87,7 +87,7 @@ function testLocalUserCreation() { $user = user_load_by_name($username); $this->assertEqual($user->getPreferredLangcode(), $langcode, 'New user has correct preferred language set.'); - $this->assertEqual($user->language()->id, $langcode, 'New user has correct profile language set.'); + $this->assertEqual($user->language()->getId(), $langcode, 'New user has correct profile language set.'); // Test if the admin can use the language selector and if the // correct language is was saved. diff --git a/core/modules/user/lib/Drupal/user/Tests/UserRegistrationTest.php b/core/modules/user/lib/Drupal/user/Tests/UserRegistrationTest.php index a0b205c..6c07b09 100644 --- a/core/modules/user/lib/Drupal/user/Tests/UserRegistrationTest.php +++ b/core/modules/user/lib/Drupal/user/Tests/UserRegistrationTest.php @@ -8,7 +8,6 @@ namespace Drupal\user\Tests; use Drupal\Core\Field\FieldDefinitionInterface; -use Drupal\Core\Language\Language; use Drupal\simpletest\WebTestBase; /** @@ -189,8 +188,8 @@ function testRegistrationDefaultValues() { $this->assertTrue(($new_user->getCreatedTime() > REQUEST_TIME - 20 ), 'Correct creation time.'); $this->assertEqual($new_user->isActive(), $config_user_settings->get('register') == USER_REGISTER_VISITORS ? 1 : 0, 'Correct status field.'); $this->assertEqual($new_user->getTimezone(), $config_system_date->get('timezone.default'), 'Correct time zone field.'); - $this->assertEqual($new_user->langcode->value, \Drupal::languageManager()->getDefaultLanguage()->id, 'Correct language field.'); - $this->assertEqual($new_user->preferred_langcode->value, \Drupal::languageManager()->getDefaultLanguage()->id, 'Correct preferred language field.'); + $this->assertEqual($new_user->langcode->value, \Drupal::languageManager()->getDefaultLanguage()->getId(), 'Correct language field.'); + $this->assertEqual($new_user->preferred_langcode->value, \Drupal::languageManager()->getDefaultLanguage()->getId(), 'Correct preferred language field.'); $this->assertEqual($new_user->init->value, $mail, 'Correct init field.'); } diff --git a/core/modules/user/lib/Drupal/user/Tests/UserRoleAdminTest.php b/core/modules/user/lib/Drupal/user/Tests/UserRoleAdminTest.php index 0ddfa73..04361b2 100644 --- a/core/modules/user/lib/Drupal/user/Tests/UserRoleAdminTest.php +++ b/core/modules/user/lib/Drupal/user/Tests/UserRoleAdminTest.php @@ -32,7 +32,7 @@ function setUp() { */ function testRoleAdministration() { $this->drupalLogin($this->admin_user); - $default_langcode = \Drupal::languageManager()->getDefaultLanguage()->id; + $default_langcode = \Drupal::languageManager()->getDefaultLanguage()->getId(); // Test presence of tab. $this->drupalGet('admin/people/permissions'); $tabs = $this->xpath('//ul[@class=:classes and //a[contains(., :text)]]', array( diff --git a/core/modules/user/lib/Drupal/user/Tests/UserTokenReplaceTest.php b/core/modules/user/lib/Drupal/user/Tests/UserTokenReplaceTest.php index c9be29c..e87fbe1 100644 --- a/core/modules/user/lib/Drupal/user/Tests/UserTokenReplaceTest.php +++ b/core/modules/user/lib/Drupal/user/Tests/UserTokenReplaceTest.php @@ -66,17 +66,17 @@ function testUserTokenReplacement() { $tests['[user:mail]'] = check_plain($account->getEmail()); $tests['[user:url]'] = url("user/" . $account->id(), $url_options); $tests['[user:edit-url]'] = url("user/" . $account->id() . "/edit", $url_options); - $tests['[user:last-login]'] = format_date($account->getLastLoginTime(), 'medium', '', NULL, $language_interface->id); - $tests['[user:last-login:short]'] = format_date($account->getLastLoginTime(), 'short', '', NULL, $language_interface->id); - $tests['[user:created]'] = format_date($account->getCreatedTime(), 'medium', '', NULL, $language_interface->id); - $tests['[user:created:short]'] = format_date($account->getCreatedTime(), 'short', '', NULL, $language_interface->id); + $tests['[user:last-login]'] = format_date($account->getLastLoginTime(), 'medium', '', NULL, $language_interface->getId()); + $tests['[user:last-login:short]'] = format_date($account->getLastLoginTime(), 'short', '', NULL, $language_interface->getId()); + $tests['[user:created]'] = format_date($account->getCreatedTime(), 'medium', '', NULL, $language_interface->getId()); + $tests['[user:created:short]'] = format_date($account->getCreatedTime(), 'short', '', NULL, $language_interface->getId()); $tests['[current-user:name]'] = check_plain(user_format_name($global_account)); // Test to make sure that we generated something for each token. $this->assertFalse(in_array(0, array_map('strlen', $tests)), 'No empty tokens generated.'); foreach ($tests as $input => $expected) { - $output = $token_service->replace($input, array('user' => $account), array('langcode' => $language_interface->id)); + $output = $token_service->replace($input, array('user' => $account), array('langcode' => $language_interface->getId())); $this->assertEqual($output, $expected, format_string('Sanitized user token %token replaced.', array('%token' => $input))); } @@ -86,7 +86,7 @@ function testUserTokenReplacement() { $tests['[current-user:name]'] = user_format_name($global_account); foreach ($tests as $input => $expected) { - $output = $token_service->replace($input, array('user' => $account), array('langcode' => $language_interface->id, 'sanitize' => FALSE)); + $output = $token_service->replace($input, array('user' => $account), array('langcode' => $language_interface->getId(), 'sanitize' => FALSE)); $this->assertEqual($output, $expected, format_string('Unsanitized user token %token replaced.', array('%token' => $input))); } @@ -98,7 +98,7 @@ function testUserTokenReplacement() { // Generate tokens with interface language. $link = url('user', array('absolute' => TRUE)); foreach ($tests as $input => $expected) { - $output = $token_service->replace($input, array('user' => $account), array('langcode' => $language_interface->id, 'callback' => 'user_mail_tokens', 'sanitize' => FALSE, 'clear' => TRUE)); + $output = $token_service->replace($input, array('user' => $account), array('langcode' => $language_interface->getId(), 'callback' => 'user_mail_tokens', 'sanitize' => FALSE, 'clear' => TRUE)); $this->assertTrue(strpos($output, $link) === 0, 'Generated URL is in interface language.'); } diff --git a/core/modules/user/user.install b/core/modules/user/user.install index 086a5a0..db8dcde 100644 --- a/core/modules/user/user.install +++ b/core/modules/user/user.install @@ -220,7 +220,7 @@ function user_install() { $storage = \Drupal::entityManager()->getStorage('user'); // @todo Rely on the default value for langcode in // https://drupal.org/node/1966436 - $langcode = \Drupal::languageManager()->getDefaultLanguage()->id; + $langcode = \Drupal::languageManager()->getDefaultLanguage()->getId(); // Insert a row for the anonymous user. $storage ->create(array( diff --git a/core/modules/user/user.module b/core/modules/user/user.module index 3fe1f1c..db87621 100644 --- a/core/modules/user/user.module +++ b/core/modules/user/user.module @@ -1472,7 +1472,7 @@ function _user_mail_notify($op, $account, $langcode = NULL) { if ($op == 'register_pending_approval') { // If a user registered requiring admin approval, notify the admin, too. // We use the site default language for this. - drupal_mail('user', 'register_pending_approval_admin', $site_mail, \Drupal::languageManager()->getDefaultLanguage()->id, $params); + drupal_mail('user', 'register_pending_approval_admin', $site_mail, \Drupal::languageManager()->getDefaultLanguage()->getId(), $params); } } return empty($mail) ? NULL : $mail['result']; diff --git a/core/modules/views/lib/Drupal/views/Entity/Render/DefaultLanguageRenderer.php b/core/modules/views/lib/Drupal/views/Entity/Render/DefaultLanguageRenderer.php index 18875f5..2e99c12 100644 --- a/core/modules/views/lib/Drupal/views/Entity/Render/DefaultLanguageRenderer.php +++ b/core/modules/views/lib/Drupal/views/Entity/Render/DefaultLanguageRenderer.php @@ -24,7 +24,7 @@ class DefaultLanguageRenderer extends RendererBase { * A language code. */ protected function getLangcode(ResultRow $row) { - return $row->_entity->getUntranslated()->language()->id; + return $row->_entity->getUntranslated()->language()->getId(); } } diff --git a/core/modules/views/lib/Drupal/views/Plugin/views/cache/CachePluginBase.php b/core/modules/views/lib/Drupal/views/Plugin/views/cache/CachePluginBase.php index 4f2503c..38ff388 100644 --- a/core/modules/views/lib/Drupal/views/Plugin/views/cache/CachePluginBase.php +++ b/core/modules/views/lib/Drupal/views/Plugin/views/cache/CachePluginBase.php @@ -8,7 +8,6 @@ namespace Drupal\views\Plugin\views\cache; use Drupal\Core\Cache\Cache; -use Drupal\Core\Language\Language; use Drupal\views\Plugin\views\PluginBase; use Drupal\Core\Database\Query\Select; @@ -294,7 +293,7 @@ public function generateResultsKey() { 'build_info' => $build_info, 'roles' => $user->getRoles(), 'super-user' => $user->id() == 1, // special caching for super user. - 'langcode' => \Drupal::languageManager()->getCurrentLanguage()->id, + 'langcode' => \Drupal::languageManager()->getCurrentLanguage()->getId(), 'base_url' => $GLOBALS['base_url'], ); $request = \Drupal::request(); @@ -324,7 +323,7 @@ public function generateOutputKey() { 'roles' => $user->getRoles(), 'super-user' => $user->id() == 1, // special caching for super user. 'theme' => $GLOBALS['theme'], - 'langcode' => \Drupal::languageManager()->getCurrentLanguage()->id, + 'langcode' => \Drupal::languageManager()->getCurrentLanguage()->getId(), 'base_url' => $GLOBALS['base_url'], ); diff --git a/core/modules/views/lib/Drupal/views/Plugin/views/display/DisplayPluginBase.php b/core/modules/views/lib/Drupal/views/Plugin/views/display/DisplayPluginBase.php index 750546f..a8c650a 100644 --- a/core/modules/views/lib/Drupal/views/Plugin/views/display/DisplayPluginBase.php +++ b/core/modules/views/lib/Drupal/views/Plugin/views/display/DisplayPluginBase.php @@ -9,7 +9,7 @@ use Drupal\Component\Utility\String; use Drupal\Core\Cache\Cache; -use Drupal\Core\Language\Language; +use Drupal\Core\Language\LanguageInterface; use Drupal\Core\Session\AccountInterface; use Drupal\Core\Theme\Registry; use Drupal\views\Plugin\views\area\AreaPluginBase; @@ -158,7 +158,7 @@ public function initDisplay(ViewExecutable $view, array &$display, array &$optio $skip_cache = \Drupal::config('views.settings')->get('skip_cache'); if (empty($view->editing) || !$skip_cache) { - $cid = 'views:unpack_options:' . hash('sha256', serialize(array($this->options, $options))) . ':' . \Drupal::languageManager()->getCurrentLanguage()->id; + $cid = 'views:unpack_options:' . hash('sha256', serialize(array($this->options, $options))) . ':' . \Drupal::languageManager()->getCurrentLanguage()->getId(); if (empty(static::$unpackOptions[$cid])) { $cache = \Drupal::cache('data')->get($cid); if (!empty($cache->data)) { @@ -1243,7 +1243,7 @@ public function optionsSummary(&$categories, &$options) { $languages = array( '***CURRENT_LANGUAGE***' => t("Current user's language"), '***DEFAULT_LANGUAGE***' => t("Default site language"), - Language::LANGCODE_NOT_SPECIFIED => t('Language neutral'), + LanguageInterface::LANGCODE_NOT_SPECIFIED => t('Language neutral'), ); if (\Drupal::moduleHandler()->moduleExists('language')) { $languages = array_merge($languages, language_list()); @@ -1617,7 +1617,7 @@ public function buildOptionsForm(&$form, &$form_state) { $languages = array( '***CURRENT_LANGUAGE***' => t("Current user's language"), '***DEFAULT_LANGUAGE***' => t("Default site language"), - Language::LANGCODE_NOT_SPECIFIED => t('Language neutral'), + LanguageInterface::LANGCODE_NOT_SPECIFIED => t('Language neutral'), ); $languages = array_merge($languages, views_language_list()); diff --git a/core/modules/views/lib/Drupal/views/Plugin/views/wizard/WizardPluginBase.php b/core/modules/views/lib/Drupal/views/Plugin/views/wizard/WizardPluginBase.php index 4ed08e4..c31217f 100644 --- a/core/modules/views/lib/Drupal/views/Plugin/views/wizard/WizardPluginBase.php +++ b/core/modules/views/lib/Drupal/views/Plugin/views/wizard/WizardPluginBase.php @@ -634,7 +634,7 @@ protected function instantiateView($form, &$form_state) { 'label' => $form_state['values']['label'], 'description' => $form_state['values']['description'], 'base_table' => $this->base_table, - 'langcode' => language_default()->id, + 'langcode' => language_default()->getId(), ); $view = entity_create('view', $values); diff --git a/core/modules/views/lib/Drupal/views/Tests/DefaultViewsTest.php b/core/modules/views/lib/Drupal/views/Tests/DefaultViewsTest.php index 6e74149..513c3b2 100644 --- a/core/modules/views/lib/Drupal/views/Tests/DefaultViewsTest.php +++ b/core/modules/views/lib/Drupal/views/Tests/DefaultViewsTest.php @@ -8,7 +8,7 @@ namespace Drupal\views\Tests; use Drupal\comment\CommentInterface; -use Drupal\Core\Language\Language; +use Drupal\Core\Language\LanguageInterface; use Drupal\simpletest\WebTestBase; use Drupal\views\ViewExecutable; use Drupal\views\Views; @@ -54,7 +54,7 @@ protected function setUp() { 'name' => $this->randomName(), 'description' => $this->randomName(), 'vid' => drupal_strtolower($this->randomName()), - 'langcode' => Language::LANGCODE_NOT_SPECIFIED, + 'langcode' => LanguageInterface::LANGCODE_NOT_SPECIFIED, 'help' => '', 'nodes' => array('page' => 'page'), 'weight' => mt_rand(0, 10), @@ -164,7 +164,7 @@ function createTerm($vocabulary) { // Use the first available text format. 'format' => $format->format, 'vid' => $vocabulary->id(), - 'langcode' => Language::LANGCODE_NOT_SPECIFIED, + 'langcode' => LanguageInterface::LANGCODE_NOT_SPECIFIED, )); $term->save(); return $term; diff --git a/core/modules/views/lib/Drupal/views/Tests/Entity/RowEntityRenderersTest.php b/core/modules/views/lib/Drupal/views/Tests/Entity/RowEntityRenderersTest.php index 869ad88..3147d5f 100644 --- a/core/modules/views/lib/Drupal/views/Tests/Entity/RowEntityRenderersTest.php +++ b/core/modules/views/lib/Drupal/views/Tests/Entity/RowEntityRenderersTest.php @@ -63,7 +63,7 @@ protected function setUp() { // The node.view route must exist when nodes are rendered. $this->container->get('router.builder')->rebuild(); - $this->langcodes = array(\Drupal::languageManager()->getDefaultLanguage()->id); + $this->langcodes = array(\Drupal::languageManager()->getDefaultLanguage()->getId()); for ($i = 0; $i < 2; $i++) { $langcode = 'l' . $i; $this->langcodes[] = $langcode; diff --git a/core/modules/views/lib/Drupal/views/Tests/Handler/AreaEntityTest.php b/core/modules/views/lib/Drupal/views/Tests/Handler/AreaEntityTest.php index 5751042..f2a42fc 100644 --- a/core/modules/views/lib/Drupal/views/Tests/Handler/AreaEntityTest.php +++ b/core/modules/views/lib/Drupal/views/Tests/Handler/AreaEntityTest.php @@ -8,7 +8,6 @@ namespace Drupal\views\Tests\Handler; use Drupal\Core\Entity\EntityTypeInterface; -use Drupal\Core\Language\Language; use Drupal\views\Tests\ViewTestBase; use Drupal\views\Views; diff --git a/core/modules/views/lib/Drupal/views/Tests/ViewsTaxonomyAutocompleteTest.php b/core/modules/views/lib/Drupal/views/Tests/ViewsTaxonomyAutocompleteTest.php index 766ae49..98611a7 100644 --- a/core/modules/views/lib/Drupal/views/Tests/ViewsTaxonomyAutocompleteTest.php +++ b/core/modules/views/lib/Drupal/views/Tests/ViewsTaxonomyAutocompleteTest.php @@ -9,7 +9,7 @@ use Drupal\Component\Utility\String; use Drupal\views\Tests\ViewTestBase; -use Drupal\Core\Language\Language; +use Drupal\Core\Language\LanguageInterface; /** * Tests the views taxonomy complete menu callback. @@ -105,7 +105,7 @@ protected function createTerm($name = NULL) { 'name' => $name ?: $this->randomName(), 'description' => $this->randomName(), 'vid' => $this->vocabulary->id(), - 'langcode' => Language::LANGCODE_NOT_SPECIFIED, + 'langcode' => LanguageInterface::LANGCODE_NOT_SPECIFIED, )); $term->save(); return $term; diff --git a/core/modules/views/lib/Drupal/views/ViewAccessController.php b/core/modules/views/lib/Drupal/views/ViewAccessController.php index e761af2..3b22203 100644 --- a/core/modules/views/lib/Drupal/views/ViewAccessController.php +++ b/core/modules/views/lib/Drupal/views/ViewAccessController.php @@ -9,7 +9,6 @@ use Drupal\Core\Entity\EntityAccessController; use Drupal\Core\Entity\EntityInterface; -use Drupal\Core\Language\Language; use Drupal\Core\Session\AccountInterface; /** diff --git a/core/modules/views/lib/Drupal/views/ViewsData.php b/core/modules/views/lib/Drupal/views/ViewsData.php index 3fccb8f..f329c36 100644 --- a/core/modules/views/lib/Drupal/views/ViewsData.php +++ b/core/modules/views/lib/Drupal/views/ViewsData.php @@ -96,7 +96,7 @@ public function __construct(CacheBackendInterface $cache_backend, ConfigFactoryI $this->moduleHandler = $module_handler; $this->languageManager = $language_manager; - $this->langcode = $this->languageManager->getCurrentLanguage()->id; + $this->langcode = $this->languageManager->getCurrentLanguage()->getId(); $this->skipCache = $config->get('views.settings')->get('skip_cache'); } diff --git a/core/modules/views/views.api.php b/core/modules/views/views.api.php index f1551e2..1763c19 100644 --- a/core/modules/views/views.api.php +++ b/core/modules/views/views.api.php @@ -341,8 +341,8 @@ function hook_views_query_substitutions(ViewExecutable $view) { return array( '***CURRENT_VERSION***' => \Drupal::VERSION, '***CURRENT_TIME***' => REQUEST_TIME, - '***CURRENT_LANGUAGE***' => \Drupal::languageManager()->getCurrentLanguage(\Drupal\Core\Language\Language::TYPE_CONTENT)->id, - '***DEFAULT_LANGUAGE***' => \Drupal::languageManager()->getDefaultLanguage()->id, + '***CURRENT_LANGUAGE***' => \Drupal::languageManager()->getCurrentLanguage(\Drupal\Core\Language\LanguageInterface::TYPE_CONTENT)->getId(), + '***DEFAULT_LANGUAGE***' => \Drupal::languageManager()->getDefaultLanguage()->getId(), ); } diff --git a/core/modules/views/views.module b/core/modules/views/views.module index 216bc93..758efac 100644 --- a/core/modules/views/views.module +++ b/core/modules/views/views.module @@ -12,7 +12,7 @@ use Drupal\Component\Utility\String; use Drupal\Core\Cache\Cache; use Drupal\Core\Database\Query\AlterableInterface; -use Drupal\Core\Language\Language; +use Drupal\Core\Language\LanguageInterface; use Drupal\Core\Render\Element; use Drupal\views\Plugin\Derivative\ViewsLocalTask; use Drupal\Core\Template\AttributeArray; @@ -507,19 +507,19 @@ function views_add_contextual_links(&$render_element, $location, ViewExecutable * array. * @param int $flags * (optional) Specifies the state of the languages that have to be returned. - * It can be: Language::STATE_CONFIGURABLE, Language::STATE_LOCKED, - * Language::STATE_ALL. + * It can be: LanguageInterface::STATE_CONFIGURABLE, LanguageInterface::STATE_LOCKED, + * LanguageInterface::STATE_ALL. * * @return array * An array of language names (or $field) keyed by the langcode. * * @see locale_language_list() */ -function views_language_list($field = 'name', $flags = Language::STATE_ALL) { +function views_language_list($field = 'name', $flags = LanguageInterface::STATE_ALL) { $languages = \Drupal::languageManager()->getLanguages($flags); $list = array(); foreach ($languages as $language) { - $list[$language->id] = ($field == 'name') ? t($language->name) : $language->$field; + $list[$language->getId()] = ($field == 'name') ? t($language->getName()) : $language->$field; } return $list; } diff --git a/core/modules/views/views.theme.inc b/core/modules/views/views.theme.inc index ae967bd..52cf376 100644 --- a/core/modules/views/views.theme.inc +++ b/core/modules/views/views.theme.inc @@ -7,7 +7,6 @@ use Drupal\Component\Utility\String; use Drupal\Component\Utility\Xss; -use Drupal\Core\Language\Language; use Drupal\Core\Template\Attribute; use Drupal\views\Form\ViewsForm; use Drupal\views\ViewExecutable; @@ -968,7 +967,7 @@ function template_preprocess_views_view_rss(&$variables) { $variables['link'] = check_url(url($path, $url_options)); } - $variables['langcode'] = String::checkPlain(\Drupal::languageManager()->getCurrentLanguage()->id); + $variables['langcode'] = String::checkPlain(\Drupal::languageManager()->getCurrentLanguage()->getId()); $variables['namespaces'] = new Attribute($style->namespaces); $variables['items'] = $items; $variables['channel_elements'] = format_xml_elements($style->channel_elements); diff --git a/core/modules/views/views.views_execution.inc b/core/modules/views/views.views_execution.inc index d1c040f..1c4f5bc 100644 --- a/core/modules/views/views.views_execution.inc +++ b/core/modules/views/views.views_execution.inc @@ -5,7 +5,7 @@ * Provides views runtime hooks for views.module. */ -use Drupal\Core\Language\Language; +use Drupal\Core\Language\LanguageInterface; use Drupal\views\ViewExecutable; /** @@ -17,7 +17,7 @@ function views_views_query_substitutions(ViewExecutable $view) { return array( '***CURRENT_VERSION***' => \Drupal::VERSION, '***CURRENT_TIME***' => REQUEST_TIME, - '***CURRENT_LANGUAGE***' => \Drupal::languageManager()->getCurrentLanguage(Language::TYPE_CONTENT)->id, - '***DEFAULT_LANGUAGE***' => \Drupal::languageManager()->getDefaultLanguage()->id, + '***CURRENT_LANGUAGE***' => \Drupal::languageManager()->getCurrentLanguage(LanguageInterface::TYPE_CONTENT)->getId(), + '***DEFAULT_LANGUAGE***' => \Drupal::languageManager()->getDefaultLanguage()->getId(), ); } diff --git a/core/modules/views_ui/tests/Drupal/views_ui/Tests/ViewUIObjectTest.php b/core/modules/views_ui/tests/Drupal/views_ui/Tests/ViewUIObjectTest.php index 7cbf7b9..f105b3a 100644 --- a/core/modules/views_ui/tests/Drupal/views_ui/Tests/ViewUIObjectTest.php +++ b/core/modules/views_ui/tests/Drupal/views_ui/Tests/ViewUIObjectTest.php @@ -7,7 +7,7 @@ namespace Drupal\views_ui\Tests; -use Drupal\Core\Language\Language; +use Drupal\Core\Language\LanguageInterface; use Drupal\Tests\UnitTestCase; use Drupal\views\ViewExecutable; use Drupal\views_ui\ViewUI; @@ -37,7 +37,7 @@ public function testEntityDecoration() { $method_args['setOriginalId'] = array(12); $method_args['setStatus'] = array(TRUE); $method_args['enforceIsNew'] = array(FALSE); - $method_args['label'] = array(Language::LANGCODE_NOT_SPECIFIED); + $method_args['label'] = array(LanguageInterface::LANGCODE_NOT_SPECIFIED); $reflection = new \ReflectionClass('Drupal\Core\Config\Entity\ConfigEntityInterface'); $interface_methods = array(); diff --git a/core/tests/Drupal/Tests/Core/Entity/EntityManagerTest.php b/core/tests/Drupal/Tests/Core/Entity/EntityManagerTest.php index 100ad29..fd82338 100644 --- a/core/tests/Drupal/Tests/Core/Entity/EntityManagerTest.php +++ b/core/tests/Drupal/Tests/Core/Entity/EntityManagerTest.php @@ -17,6 +17,7 @@ use Drupal\Core\Entity\EntityManager; use Drupal\Core\Entity\EntityTypeInterface; use Drupal\Core\Language\Language; +use Drupal\Core\Language\LanguageInterface; use Drupal\Tests\UnitTestCase; use Symfony\Component\DependencyInjection\ContainerInterface; @@ -111,12 +112,16 @@ protected function setUp() { $this->cache = $this->getMock('Drupal\Core\Cache\CacheBackendInterface'); + $language = $this->getMock('\Drupal\Core\Language\LanguageInterface'); + $language->expects($this->any()) + ->method('getId') + ->will($this->returnValue('en')); $this->languageManager = $this->getMockBuilder('Drupal\Core\Language\LanguageManager') ->disableOriginalConstructor() ->getMock(); $this->languageManager->expects($this->any()) ->method('getCurrentLanguage') - ->will($this->returnValue((object) array('id' => 'en'))); + ->will($this->returnValue($language)); $this->translationManager = $this->getStringTranslationStub(); @@ -890,13 +895,17 @@ public function testGetTranslationFromContext() { $entity->expects($this->exactly(2)) ->method('getUntranslated') ->will($this->returnValue($entity)); + $language = $this->getMock('\Drupal\Core\Language\LanguageInterface'); + $language->expects($this->any()) + ->method('getId') + ->will($this->returnValue('en')); $entity->expects($this->exactly(2)) ->method('language') - ->will($this->returnValue((object) array('id' => 'en'))); + ->will($this->returnValue($language)); $entity->expects($this->exactly(2)) ->method('hasTranslation') ->will($this->returnValueMap(array( - array(Language::LANGCODE_DEFAULT, FALSE), + array(LanguageInterface::LANGCODE_DEFAULT, FALSE), array('custom_langcode', TRUE), ))); @@ -937,7 +946,7 @@ function testgetExtraFields() { $cache_id = 'entity_bundle_extra_fields:' . $entity_type_id . ':' . $bundle . ':' . $language_code; $language = new Language(); - $language->id = $language_code; + $language->setId($language_code); $this->languageManager->expects($this->once()) ->method('getCurrentLanguage') diff --git a/core/tests/Drupal/Tests/Core/Entity/EntityUnitTest.php b/core/tests/Drupal/Tests/Core/Entity/EntityUnitTest.php index 6ccad14..592b3cc 100644 --- a/core/tests/Drupal/Tests/Core/Entity/EntityUnitTest.php +++ b/core/tests/Drupal/Tests/Core/Entity/EntityUnitTest.php @@ -236,7 +236,7 @@ public function testAccess() { * @covers ::language */ public function testLanguage() { - $this->assertSame('en', $this->entity->language()->id); + $this->assertSame('en', $this->entity->language()->getId()); } /** diff --git a/core/tests/Drupal/Tests/Core/Mail/MailManagerTest.php b/core/tests/Drupal/Tests/Core/Mail/MailManagerTest.php index 9ef8d20..e5ba12a 100644 --- a/core/tests/Drupal/Tests/Core/Mail/MailManagerTest.php +++ b/core/tests/Drupal/Tests/Core/Mail/MailManagerTest.php @@ -91,9 +91,13 @@ protected function setUp() { $this->cache = $this->getMock('Drupal\Core\Cache\CacheBackendInterface'); $this->languageManager = $this->getMock('Drupal\Core\Language\LanguageManagerInterface'); + $language = $this->getMock('\Drupal\Core\Language\LanguageInterface'); + $language->expects($this->any()) + ->method('getId') + ->will($this->returnValue('en')); $this->languageManager->expects($this->any()) ->method('getCurrentLanguage') - ->will($this->returnValue((object) array('id' => 'en'))); + ->will($this->returnValue($language)); $this->moduleHandler = $this->getMock('Drupal\Core\Extension\ModuleHandlerInterface'); diff --git a/core/tests/Drupal/Tests/Core/PathProcessor/PathProcessorTest.php b/core/tests/Drupal/Tests/Core/PathProcessor/PathProcessorTest.php index f58edc5..de80260c0 100644 --- a/core/tests/Drupal/Tests/Core/PathProcessor/PathProcessorTest.php +++ b/core/tests/Drupal/Tests/Core/PathProcessor/PathProcessorTest.php @@ -7,7 +7,7 @@ namespace Drupal\Tests\Core\PathProcessor; -use Drupal\Core\Language\Language; +use Drupal\Core\Language\LanguageInterface; use Drupal\Core\PathProcessor\PathProcessorAlias; use Drupal\Core\PathProcessor\PathProcessorDecode; use Drupal\Core\PathProcessor\PathProcessorFront; @@ -26,6 +26,9 @@ */ class PathProcessorTest extends UnitTestCase { + /** + * @var \Drupal\Core\Language\LanguageInterface[] + */ protected $languages; protected $languageManager; @@ -42,9 +45,13 @@ public function setUp() { // Set up some languages to be used by the language-based path processor. $languages = array(); foreach (array('en' => 'English', 'fr' => 'French') as $langcode => $language_name) { - $language = new \stdClass(); - $language->id = $langcode; - $language->name = $language_name; + $language = $this->getMock('\Drupal\Core\Language\LanguageInterface'); + $language->expects($this->any()) + ->method('getId') + ->will($this->returnValue($langcode)); + $language->expects($this->any()) + ->method('getName') + ->will($this->returnValue($language_name)); $languages[$langcode] = $language; } $this->languages = $languages; @@ -78,7 +85,7 @@ public function setUp() { ->will($this->returnValue($this->languages)); $language_manager->expects($this->any()) ->method('getLanguageTypes') - ->will($this->returnValue(array(Language::TYPE_INTERFACE))); + ->will($this->returnValue(array(LanguageInterface::TYPE_INTERFACE))); $language_manager->expects($this->any()) ->method('getNegotiationMethods') ->will($this->returnValue($method_definitions)); diff --git a/core/tests/Drupal/Tests/Core/Plugin/DefaultPluginManagerTest.php b/core/tests/Drupal/Tests/Core/Plugin/DefaultPluginManagerTest.php index 4862ac7..68c952c 100644 --- a/core/tests/Drupal/Tests/Core/Plugin/DefaultPluginManagerTest.php +++ b/core/tests/Drupal/Tests/Core/Plugin/DefaultPluginManagerTest.php @@ -8,6 +8,7 @@ namespace Drupal\Tests\Core\Plugin; use Drupal\Core\Language\Language; +use Drupal\Core\Language\LanguageInterface; use Drupal\Tests\UnitTestCase; /** @@ -143,7 +144,7 @@ public function testDefaultPluginManagerWithEmptyCache() { $language_manager = $this->getMock('Drupal\Core\Language\LanguageManagerInterface'); $language_manager->expects($this->once()) ->method('getCurrentLanguage') - ->with(Language::TYPE_INTERFACE) + ->with(LanguageInterface::TYPE_INTERFACE) ->will($this->returnValue($language)); $plugin_manager = new TestPluginManager($this->namespaces, $this->expectedDefinitions); @@ -174,7 +175,7 @@ public function testDefaultPluginManagerWithFilledCache() { $language_manager = $this->getMock('Drupal\Core\Language\LanguageManagerInterface'); $language_manager->expects($this->once()) ->method('getCurrentLanguage') - ->with(Language::TYPE_INTERFACE) + ->with(LanguageInterface::TYPE_INTERFACE) ->will($this->returnValue($language)); $plugin_manager = new TestPluginManager($this->namespaces, $this->expectedDefinitions); @@ -205,7 +206,7 @@ public function testCacheClearWithTags() { $language_manager = $this->getMock('Drupal\Core\Language\LanguageManagerInterface'); $language_manager->expects($this->once()) ->method('getCurrentLanguage') - ->with(Language::TYPE_INTERFACE) + ->with(LanguageInterface::TYPE_INTERFACE) ->will($this->returnValue($language)); $plugin_manager = new TestPluginManager($this->namespaces, $this->expectedDefinitions); diff --git a/core/tests/Drupal/Tests/Core/Utility/TokenTest.php b/core/tests/Drupal/Tests/Core/Utility/TokenTest.php index f92502e..980ca93 100644 --- a/core/tests/Drupal/Tests/Core/Utility/TokenTest.php +++ b/core/tests/Drupal/Tests/Core/Utility/TokenTest.php @@ -8,6 +8,7 @@ namespace Drupal\Tests\Core\Utility; use Drupal\Core\Language\Language; +use Drupal\Core\Language\LanguageInterface; use Drupal\Core\Utility\Token; use Drupal\Tests\UnitTestCase; @@ -83,7 +84,7 @@ public function testGetInfo() { ); $language = $this->getMock('\Drupal\Core\Language\Language'); - $language->id = $this->randomName(); + $language->setId($this->randomName()); $this->languageManager->expects($this->once()) ->method('getCurrentLanguage') @@ -96,7 +97,7 @@ public function testGetInfo() { ->method('get'); $this->cache->expects($this->once()) ->method('set') - ->with('token_info:' . $language->id, $token_info); + ->with('token_info:' . $language->getId(), $token_info); $this->moduleHandler->expects($this->once()) ->method('invokeAll')