diff --git a/core/includes/common.inc b/core/includes/common.inc index 9589aa12117380cbd8d8872f2f7dc8aaa0503849..8d69f346e6f7a48af54abd8355970ef5bf7da992 100644 --- a/core/includes/common.inc +++ b/core/includes/common.inc @@ -752,7 +752,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. @@ -1525,7 +1525,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(LanguageInterface::TYPE_URL)->id, + 'currentLanguage' => \Drupal::languageManager()->getCurrentLanguage(LanguageInterface::TYPE_URL)->getId(), ); if (!empty($current_query)) { ksort($current_query); diff --git a/core/includes/theme.inc b/core/includes/theme.inc index 1015f67f820e8b99c50ad9686f1c97ae0b762aa3..8c947e28604ec2a8627528a7201b795443fe5cc4 100644 --- a/core/includes/theme.inc +++ b/core/includes/theme.inc @@ -1006,7 +1006,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 diff --git a/core/includes/update.inc b/core/includes/update.inc index 22baff999a7a5e30687c50304053455fae161243..aad19f2e94905bf02be8e5a11989239e0502af43 100644 --- a/core/includes/update.inc +++ b/core/includes/update.inc @@ -719,7 +719,7 @@ function update_language_list($flags = LanguageInterface::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'], @@ -731,7 +731,7 @@ function update_language_list($flags = LanguageInterface::STATE_CONFIGURABLE) { } 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->getWeight()); } diff --git a/core/lib/Drupal/Core/Cache/LanguageCacheContext.php b/core/lib/Drupal/Core/Cache/LanguageCacheContext.php index e2c1bd93bc277a80844e67f890802d9e2e5f3785..0a3f16cba9a4ac7a37f9e20940a64e384db9f9ee 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/Entity/ConfigEntityStorage.php b/core/lib/Drupal/Core/Config/Entity/ConfigEntityStorage.php index 4cad0745c361ce5b0c49b875bd3bb9c512a5fa27..f7565d1893b357e5e7252d1d0b4f02f3e7360015 100644 --- a/core/lib/Drupal/Core/Config/Entity/ConfigEntityStorage.php +++ b/core/lib/Drupal/Core/Config/Entity/ConfigEntityStorage.php @@ -189,7 +189,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); return $entity; diff --git a/core/lib/Drupal/Core/Datetime/DateFormatter.php b/core/lib/Drupal/Core/Datetime/DateFormatter.php index b97f2e1d10b0f78a9e79db5a960c6339237d8258..0b4f817f46fd5013fb146edf8fba84507a079ba0 100644 --- a/core/lib/Drupal/Core/Datetime/DateFormatter.php +++ b/core/lib/Drupal/Core/Datetime/DateFormatter.php @@ -133,7 +133,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 78b3f1c8dad6a9967fd6aa297765164f4627cf49..2f071089e12bce3e261954bf40c8605cff3d557e 100644 --- a/core/lib/Drupal/Core/Datetime/DrupalDateTime.php +++ b/core/lib/Drupal/Core/Datetime/DrupalDateTime.php @@ -43,7 +43,7 @@ class DrupalDateTime extends DateTimePlus { */ public function __construct($time = 'now', $timezone = NULL, $settings = array()) { if (!isset($settings['langcode'])) { - $settings['langcode'] = \Drupal::languageManager()->getCurrentLanguage()->id; + $settings['langcode'] = \Drupal::languageManager()->getCurrentLanguage()->getId(); } // Instantiate the parent class. diff --git a/core/lib/Drupal/Core/Entity/ContentEntityBase.php b/core/lib/Drupal/Core/Entity/ContentEntityBase.php index 636c00b7d96c3cc8ff5d459b287b49e68c87b0e6..76b8fd205c1805e915134def477b7322801e15c8 100644 --- a/core/lib/Drupal/Core/Entity/ContentEntityBase.php +++ b/core/lib/Drupal/Core/Entity/ContentEntityBase.php @@ -475,7 +475,7 @@ 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)) { diff --git a/core/lib/Drupal/Core/Entity/ContentEntityForm.php b/core/lib/Drupal/Core/Entity/ContentEntityForm.php index 64374cf87499b5c8f63def5429a84c0fcb4ac995..75c4927393831b225562adabf8589191154bfb68 100644 --- a/core/lib/Drupal/Core/Entity/ContentEntityForm.php +++ b/core/lib/Drupal/Core/Entity/ContentEntityForm.php @@ -91,7 +91,7 @@ public function getFormLangcode(FormStateInterface $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->set('langcode', $this->entityManager->getTranslationFromContext($this->entity)->language()->id); + $form_state->set('langcode', $this->entityManager->getTranslationFromContext($this->entity)->language()->getId()); } return $form_state->get('langcode'); } @@ -100,7 +100,7 @@ public function getFormLangcode(FormStateInterface $form_state) { * {@inheritdoc} */ public function isDefaultFormLangcode(FormStateInterface $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/EntityManager.php b/core/lib/Drupal/Core/Entity/EntityManager.php index 9560c715780d39cd175a2f4daf049d5929b6398f..32262395c82d920c25bf7d86ec55907f14299be7 100644 --- a/core/lib/Drupal/Core/Entity/EntityManager.php +++ b/core/lib/Drupal/Core/Entity/EntityManager.php @@ -335,7 +335,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->cacheBackend->get($cid)) { $this->baseFieldDefinitions[$entity_type_id] = $cache->data; } @@ -433,7 +433,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->cacheBackend->get($cid)) { $bundle_field_definitions = $cache->data; } @@ -541,7 +541,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->cacheBackend->get($cid)) { $field_storage_definitions = $cache->data; } @@ -680,7 +680,7 @@ public function getBundleInfo($entity_type) { */ public function getAllBundleInfo() { if (empty($this->bundleInfo)) { - $langcode = $this->languageManager->getCurrentLanguage()->id; + $langcode = $this->languageManager->getCurrentLanguage()->getId(); if ($cache = $this->cacheBackend->get("entity_bundle_info:$langcode")) { $this->bundleInfo = $cache->data; } @@ -721,7 +721,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->cacheBackend->get($cache_id); if ($cached) { $this->extraFields[$entity_type_id][$bundle] = $cached->data; @@ -783,7 +783,7 @@ public function getTranslationFromContext(EntityInterface $entity, $langcode = N if ($entity instanceof TranslatableInterface) { if (empty($langcode)) { - $langcode = $this->languageManager->getCurrentLanguage(LanguageInterface::TYPE_CONTENT)->id; + $langcode = $this->languageManager->getCurrentLanguage(LanguageInterface::TYPE_CONTENT)->getId(); } // Retrieve language fallback candidates to perform the entity language @@ -794,7 +794,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] = LanguageInterface::LANGCODE_DEFAULT; + $candidates[$default_language->getId()] = LanguageInterface::LANGCODE_DEFAULT; // Return the most fitting entity translation. foreach ($candidates as $candidate) { @@ -849,7 +849,7 @@ protected function getAllDisplayModesByEntityType($display_type) { if (!isset($this->displayModeInfo[$display_type])) { $key = 'entity_' . $display_type . '_info'; $entity_type_id = 'entity_' . $display_type; - $langcode = $this->languageManager->getCurrentLanguage(LanguageInterface::TYPE_INTERFACE)->id; + $langcode = $this->languageManager->getCurrentLanguage(LanguageInterface::TYPE_INTERFACE)->getId(); if ($cache = $this->cacheBackend->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 91cfc34236a48edc433d1738a2bacb247c5fec05..e31c1332421970182d17a0a58edbad642691c8c1 100644 --- a/core/lib/Drupal/Core/Entity/EntityViewBuilder.php +++ b/core/lib/Drupal/Core/Entity/EntityViewBuilder.php @@ -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(LanguageInterface::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 3d34f76f58a3100281cd15ca89bc66193a44f71c..7faeccc116152ef51cd6b1be9978ad6aefd04681 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/Entity/Sql/SqlContentEntityStorage.php b/core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorage.php index 454944ce83c2b0f6b17219240add43b7add2b35a..2aa54768064186e6c70a0849924fd38f0b3d83c2 100644 --- a/core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorage.php +++ b/core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorage.php @@ -1112,8 +1112,8 @@ protected function mapToDataStorageRecord(EntityInterface $entity, $table_name = $table_name = $this->dataTable; } $record = $this->mapToStorageRecord($entity, $table_name); - $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; } @@ -1199,7 +1199,7 @@ protected function loadFieldItems(array $entities) { 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. @@ -1275,7 +1275,7 @@ protected function saveFieldItems(EntityInterface $entity, $update = TRUE) { $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()); $table_mapping = $this->getTableMapping(); diff --git a/core/lib/Drupal/Core/EventSubscriber/FinishResponseSubscriber.php b/core/lib/Drupal/Core/EventSubscriber/FinishResponseSubscriber.php index 55330918b85b43fcf98b83a1b9ee01a5d7d53e6d..42600fd4cd69a61fd1e7090d1076cdf4bcab6c7f 100644 --- a/core/lib/Drupal/Core/EventSubscriber/FinishResponseSubscriber.php +++ b/core/lib/Drupal/Core/EventSubscriber/FinishResponseSubscriber.php @@ -94,7 +94,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/Language/Language.php b/core/lib/Drupal/Core/Language/Language.php index 84bf55a49637f31fe601ac56aa9dce17091e3e61..175f9fb9528ad0dd57c1339c86276a68c74364ce 100644 --- a/core/lib/Drupal/Core/Language/Language.php +++ b/core/lib/Drupal/Core/Language/Language.php @@ -41,7 +41,7 @@ class Language implements LanguageInterface { * * @var string */ - public $id = ''; + protected $id = ''; /** * The direction, left-to-right, or right-to-left. diff --git a/core/lib/Drupal/Core/Language/LanguageManager.php b/core/lib/Drupal/Core/Language/LanguageManager.php index ee8bd2acff961df86d0ad8b979acb90d4db597e4..557faad6933d253751bf0c733f7726f73ff64acc 100644 --- a/core/lib/Drupal/Core/Language/LanguageManager.php +++ b/core/lib/Drupal/Core/Language/LanguageManager.php @@ -134,7 +134,7 @@ public function getLanguages($flags = LanguageInterface::STATE_CONFIGURABLE) { 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->getWeight()); } diff --git a/core/lib/Drupal/Core/Page/DefaultHtmlFragmentRenderer.php b/core/lib/Drupal/Core/Page/DefaultHtmlFragmentRenderer.php index d4f4970c08fb1f7c709f9d41f4a6f31e19ce8de8..115edd6fbc7023cb76e21d8ceb5e9eb88c01fc7a 100644 --- a/core/lib/Drupal/Core/Page/DefaultHtmlFragmentRenderer.php +++ b/core/lib/Drupal/Core/Page/DefaultHtmlFragmentRenderer.php @@ -100,7 +100,7 @@ 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['lang'] = $language_interface->getId(); $html_attributes['dir'] = $language_interface->getDirection(); $this->setDefaultMetaTags($page); diff --git a/core/lib/Drupal/Core/Path/AliasManager.php b/core/lib/Drupal/Core/Path/AliasManager.php index bca2eea1bac641fd249d1e2bbf05e48c5f0d6537..f09fd7cf3d8aacd32d944630cef101166ad00f25 100644 --- a/core/lib/Drupal/Core/Path/AliasManager.php +++ b/core/lib/Drupal/Core/Path/AliasManager.php @@ -157,7 +157,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(LanguageInterface::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])) { @@ -191,7 +191,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(LanguageInterface::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/PathProcessor/PathProcessorAlias.php b/core/lib/Drupal/Core/PathProcessor/PathProcessorAlias.php index 1c709a11637419ccfc684d1a9f1727997c5d9671..67226ab926cd62b62d3a24f701300b6b5d410533 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/Render/Element/MachineName.php b/core/lib/Drupal/Core/Render/Element/MachineName.php index f062a8c67be9a85f6722e3892ec795e82497f569..24ac3a43b6b6e7289302d24df2c927e78c2e5825 100644 --- a/core/lib/Drupal/Core/Render/Element/MachineName.php +++ b/core/lib/Drupal/Core/Render/Element/MachineName.php @@ -170,7 +170,7 @@ public static function processMachineName(&$element, FormStateInterface $form_st 'machineName' => array( '#' . $source['#id'] => $element['#machine_name'], ), - 'langcode' => $language->id, + 'langcode' => $language->getId(), ), ); $element['#attached']['library'][] = 'core/drupal.machine-name'; diff --git a/core/lib/Drupal/Core/Session/UserSession.php b/core/lib/Drupal/Core/Session/UserSession.php index 7364da993c1888273390d73c59851e69e56871d0..feb935c0375970e4882f33043e4a19f23576515e 100644 --- a/core/lib/Drupal/Core/Session/UserSession.php +++ b/core/lib/Drupal/Core/Session/UserSession.php @@ -185,10 +185,10 @@ public function isAnonymous() { function getPreferredLangcode($fallback_to_default = TRUE) { $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 $fallback_to_default ? language_default()->id : ''; + return $fallback_to_default ? language_default()->getId() : ''; } } @@ -198,10 +198,10 @@ function getPreferredLangcode($fallback_to_default = TRUE) { function getPreferredAdminLangcode($fallback_to_default = TRUE) { $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 $fallback_to_default ? language_default()->id : ''; + return $fallback_to_default ? language_default()->getId() : ''; } } diff --git a/core/lib/Drupal/Core/StringTranslation/TranslationManager.php b/core/lib/Drupal/Core/StringTranslation/TranslationManager.php index 8080d4b0e0e6bdc1a967145a7bc39193376c8e11..cdfc2dff5f8a55fd2934e4c3f2741c646c726845 100644 --- a/core/lib/Drupal/Core/StringTranslation/TranslationManager.php +++ b/core/lib/Drupal/Core/StringTranslation/TranslationManager.php @@ -61,7 +61,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 3a0780f59587332593d74bf06d6bdc18a67f11e5..61cdc73d35fe8f987524005691f27b3756a17ecc 100644 --- a/core/lib/Drupal/Core/TypedData/Plugin/DataType/Language.php +++ b/core/lib/Drupal/Core/TypedData/Plugin/DataType/Language.php @@ -56,7 +56,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)) { @@ -88,7 +88,7 @@ public function id() { return $this->id; } elseif (isset($this->language)) { - return $this->language->id; + return $this->language->getId(); } } diff --git a/core/lib/Drupal/Core/Utility/LinkGenerator.php b/core/lib/Drupal/Core/Utility/LinkGenerator.php index b029327a9935e447c24cd6c8eda6f480312b3ce4..857819578499b52c7a0683ba0ab7b8effb98f8fe 100644 --- a/core/lib/Drupal/Core/Utility/LinkGenerator.php +++ b/core/lib/Drupal/Core/Utility/LinkGenerator.php @@ -94,7 +94,7 @@ public function generate($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 a59becb58624d41d0145f634638b8a501862d24c..7c1a805a1f704d441ffd0c88cf042a552fb4c61e 100644 --- a/core/lib/Drupal/Core/Utility/Token.php +++ b/core/lib/Drupal/Core/Utility/Token.php @@ -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(LanguageInterface::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 01302ce80e3233a1111fc57604c6dca6f677817c..84847a59537df6bcef2369179b665a2b801b508b 100644 --- a/core/lib/Drupal/Core/Validation/DrupalTranslator.php +++ b/core/lib/Drupal/Core/Validation/DrupalTranslator.php @@ -55,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/action/src/Plugin/Action/EmailAction.php b/core/modules/action/src/Plugin/Action/EmailAction.php index 58409d1fc4a047868b7599311a944125412595b3..2a1e3a907e68b64e126b71ef23c536fee69779b8 100644 --- a/core/modules/action/src/Plugin/Action/EmailAction.php +++ b/core/modules/action/src/Plugin/Action/EmailAction.php @@ -101,7 +101,7 @@ public function execute($entity = NULL) { $langcode = $recipient_account->getPreferredLangcode(); } else { - $langcode = language_default()->id; + $langcode = language_default()->getId(); } $params = array('context' => $this->configuration); diff --git a/core/modules/aggregator/src/FeedForm.php b/core/modules/aggregator/src/FeedForm.php index f22de7412e9bc2215524900d2be274d29c8e5d98..251bb44845d3469ce81a40a43c0752a894dbc7e5 100644 --- a/core/modules/aggregator/src/FeedForm.php +++ b/core/modules/aggregator/src/FeedForm.php @@ -32,7 +32,7 @@ public function form(array $form, FormStateInterface $form_state) { $form['langcode'] = array( '#title' => $this->t('Language'), '#type' => 'language_select', - '#default_value' => $feed->language()->id, + '#default_value' => $feed->language()->getId(), '#languages' => LanguageInterface::STATE_ALL, '#weight' => -4, ); diff --git a/core/modules/aggregator/src/Plugin/aggregator/processor/DefaultProcessor.php b/core/modules/aggregator/src/Plugin/aggregator/processor/DefaultProcessor.php index fdc10dc6f19f41010e6fbfe9d658b342be993219..199e224492f2c59318d89436e450c4ed223ef2e2 100644 --- a/core/modules/aggregator/src/Plugin/aggregator/processor/DefaultProcessor.php +++ b/core/modules/aggregator/src/Plugin/aggregator/processor/DefaultProcessor.php @@ -206,7 +206,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/src/Tests/FeedLanguageTest.php b/core/modules/aggregator/src/Tests/FeedLanguageTest.php index 0d4e4814806a51d8a4fe8d30011b89821abb63ef..09c608c93178b59da0dd0b761107efffe4b134af 100644 --- a/core/modules/aggregator/src/Tests/FeedLanguageTest.php +++ b/core/modules/aggregator/src/Tests/FeedLanguageTest.php @@ -56,8 +56,8 @@ public function testFeedLanguage() { $feeds[2] = $this->createFeed(NULL, array('langcode' => $this->langcodes[2])); // Make sure that the language has been assigned. - $this->assertEqual($feeds[1]->language()->id, $this->langcodes[1]); - $this->assertEqual($feeds[2]->language()->id, $this->langcodes[2]); + $this->assertEqual($feeds[1]->language()->getId(), $this->langcodes[1]); + $this->assertEqual($feeds[2]->language()->getId(), $this->langcodes[2]); // Create example nodes to create feed items from and then update the feeds. $this->createSampleNodes(); @@ -70,7 +70,7 @@ public function testFeedLanguage() { $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/src/Tests/BlockStorageUnitTest.php b/core/modules/block/src/Tests/BlockStorageUnitTest.php index b0630512687b79b5dcba946365e2bd6239915bb0..5fb4e8bedef264ccba9ad28d463d2acf6f7e0351 100644 --- a/core/modules/block/src/Tests/BlockStorageUnitTest.php +++ b/core/modules/block/src/Tests/BlockStorageUnitTest.php @@ -84,7 +84,7 @@ protected function createTests() { // Ensure that default values are filled in. $expected_properties = array( - 'langcode' => \Drupal::languageManager()->getDefaultLanguage()->id, + 'langcode' => \Drupal::languageManager()->getDefaultLanguage()->getId(), 'status' => TRUE, 'dependencies' => array('module' => array('block_test'), 'theme' => array('stark')), 'id' => 'test_block', diff --git a/core/modules/block_content/src/BlockContentForm.php b/core/modules/block_content/src/BlockContentForm.php index df923ee3fcae0172fa2a38625e25f3935469fc4b..769a7f30fdbaa865a75982ee075569c370836cea 100644 --- a/core/modules/block_content/src/BlockContentForm.php +++ b/core/modules/block_content/src/BlockContentForm.php @@ -109,14 +109,14 @@ public function form(array $form, FormStateInterface $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, + '#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_content/src/Tests/BlockContentTypeTest.php b/core/modules/block_content/src/Tests/BlockContentTypeTest.php index e08942bd3403d20eb63df79857dc4dbe030d2523..76dfdb74110a14845a589e6b755139b82bf55079 100644 --- a/core/modules/block_content/src/Tests/BlockContentTypeTest.php +++ b/core/modules/block_content/src/Tests/BlockContentTypeTest.php @@ -57,7 +57,7 @@ public function testBlockContentTypeCreation() { $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->language()->getId(), $default_langcode); } diff --git a/core/modules/book/book.module b/core/modules/book/book.module index 2d4115c0c59cf150df71980f23c1c75f7ac7947a..cea9627ad52bf5f1c08045c27c3f4cfe29915c5d 100644 --- a/core/modules/book/book.module +++ b/core/modules/book/book.module @@ -478,7 +478,7 @@ function template_preprocess_book_export_html(&$variables) { // HTML element attributes. $attributes = array(); - $attributes['lang'] = $language_interface->id; + $attributes['lang'] = $language_interface->getId(); $attributes['dir'] = $language_interface->getDirection(); $variables['html_attributes'] = new Attribute($attributes); } diff --git a/core/modules/book/src/BookManager.php b/core/modules/book/src/BookManager.php index efab6410e40e3518681081ab5ae23434fedb9ace..8f2ab352fa8ce0bb978d904e0a43a0776f0f990a 100644 --- a/core/modules/book/src/BookManager.php +++ b/core/modules/book/src/BookManager.php @@ -443,7 +443,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. @@ -596,7 +596,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/src/Plugin/Editor/CKEditor.php b/core/modules/ckeditor/src/Plugin/Editor/CKEditor.php index 6d92f98a6cd6163ecd697daa1c4f165ad6729a05..07627286ac96af64cabb56e797ee451977660c1d 100644 --- a/core/modules/ckeditor/src/Plugin/Editor/CKEditor.php +++ b/core/modules/ckeditor/src/Plugin/Editor/CKEditor.php @@ -271,8 +271,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/src/CommentForm.php b/core/modules/comment/src/CommentForm.php index 5cf5d284536fe5328b14e4541a3b2fb4fa7848f4..35e033d95714029a406447f16893659b18076d4f 100644 --- a/core/modules/comment/src/CommentForm.php +++ b/core/modules/comment/src/CommentForm.php @@ -64,7 +64,7 @@ protected function init(FormStateInterface $form_state) { // set. if ($comment->isNew()) { $language_content = \Drupal::languageManager()->getCurrentLanguage(LanguageInterface::TYPE_CONTENT); - $comment->langcode->value = $language_content->id; + $comment->langcode->value = $language_content->getId(); } parent::init($form_state); @@ -165,7 +165,7 @@ public function form(array $form, FormStateInterface $form_state) { $form['langcode'] = array( '#title' => t('Language'), '#type' => 'language_select', - '#default_value' => $comment->getUntranslated()->language()->id, + '#default_value' => $comment->getUntranslated()->language()->getId(), '#languages' => Language::STATE_ALL, '#access' => isset($language_configuration['language_show']) && $language_configuration['language_show'], ); diff --git a/core/modules/comment/src/Tests/CommentTokenReplaceTest.php b/core/modules/comment/src/Tests/CommentTokenReplaceTest.php index 76eca2939cb894a1e6ae69e3a5531542ac9e7124..c3699aecb3f90cac8566bf7590e4d6a62da6f73e 100644 --- a/core/modules/comment/src/Tests/CommentTokenReplaceTest.php +++ b/core/modules/comment/src/Tests/CommentTokenReplaceTest.php @@ -59,8 +59,8 @@ function testCommentTokenReplacement() { $tests['[comment:body]'] = $comment->comment_body->processed; $tests['[comment:url]'] = $comment->url('canonical', $url_options + array('fragment' => 'comment-' . $comment->id())); $tests['[comment:edit-url]'] = $comment->url('edit-form', $url_options); - $tests['[comment:created:since]'] = \Drupal::service('date.formatter')->formatInterval(REQUEST_TIME - $comment->getCreatedTime(), 2, $language_interface->id); - $tests['[comment:changed:since]'] = \Drupal::service('date.formatter')->formatInterval(REQUEST_TIME - $comment->getChangedTime(), 2, $language_interface->id); + $tests['[comment:created:since]'] = \Drupal::service('date.formatter')->formatInterval(REQUEST_TIME - $comment->getCreatedTime(), 2, $language_interface->getId()); + $tests['[comment:changed:since]'] = \Drupal::service('date.formatter')->formatInterval(REQUEST_TIME - $comment->getChangedTime(), 2, $language_interface->getId()); $tests['[comment:parent:cid]'] = $comment->hasParentComment() ? $comment->getParentComment()->id() : NULL; $tests['[comment:parent:title]'] = String::checkPlain($parent_comment->getSubject()); $tests['[comment:node:nid]'] = $comment->getCommentedEntityId(); @@ -72,7 +72,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))); } @@ -89,7 +89,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))); } @@ -105,7 +105,7 @@ function testCommentTokenReplacement() { $tests['[node:comment-count-new]'] = 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/comment/src/Tests/CommentTypeTest.php b/core/modules/comment/src/Tests/CommentTypeTest.php index 872d29bf5990597964f9d7556b5dde6ad9436999..4a6d1b1ce536dc37b5bf581e8f902c13835e6474 100644 --- a/core/modules/comment/src/Tests/CommentTypeTest.php +++ b/core/modules/comment/src/Tests/CommentTypeTest.php @@ -74,7 +74,7 @@ public function testCommentTypeCreation() { $this->assertTrue($comment_type, 'The new comment type has been created.'); // Check that the comment type was created in site default language. - $default_langcode = \Drupal::languageManager()->getDefaultLanguage()->id; + $default_langcode = \Drupal::languageManager()->getDefaultLanguage()->getId(); $this->assertEqual($comment_type->language()->getId(), $default_langcode); // Edit the comment-type and ensure that we cannot change the entity-type. diff --git a/core/modules/config/src/Tests/ConfigEntityTest.php b/core/modules/config/src/Tests/ConfigEntityTest.php index 0a896a0b29f3d82ab5bb4b7c0bae693d1b537c60..4bdbe250bc2c4616b2c662247e2b0f23c4c508cf 100644 --- a/core/modules/config/src/Tests/ConfigEntityTest.php +++ b/core/modules/config/src/Tests/ConfigEntityTest.php @@ -37,7 +37,7 @@ class ConfigEntityTest extends WebTestBase { * 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->assertTrue($empty->uuid()); diff --git a/core/modules/config/src/Tests/ConfigImportUITest.php b/core/modules/config/src/Tests/ConfigImportUITest.php index d4c4c9d3a7c2abc3eca48f8e4d9b4e603b7729b9..20187161c6629cdeb7b2a9f5c128bca6e5ae90aa 100644 --- a/core/modules/config/src/Tests/ConfigImportUITest.php +++ b/core/modules/config/src/Tests/ConfigImportUITest.php @@ -51,7 +51,7 @@ function testImport() { // Create new config entity. $original_dynamic_data = array( 'uuid' => '30df59bd-7b03-4cf7-bb35-d42fc49f0651', - 'langcode' => \Drupal::languageManager()->getDefaultLanguage()->id, + 'langcode' => \Drupal::languageManager()->getDefaultLanguage()->getId(), 'status' => TRUE, 'dependencies' => array(), 'id' => 'new', diff --git a/core/modules/config/src/Tests/ConfigImporterTest.php b/core/modules/config/src/Tests/ConfigImporterTest.php index e5e760e88cdcd3f9576821e4fb5a38ded81ade50..eff180c4c9a9242c1422ffef29b38af50d92b1b5 100644 --- a/core/modules/config/src/Tests/ConfigImporterTest.php +++ b/core/modules/config/src/Tests/ConfigImporterTest.php @@ -165,7 +165,7 @@ function testNew() { // Create new config entity. $original_dynamic_data = array( 'uuid' => '30df59bd-7b03-4cf7-bb35-d42fc49f0651', - 'langcode' => \Drupal::languageManager()->getDefaultLanguage()->id, + 'langcode' => \Drupal::languageManager()->getDefaultLanguage()->getId(), 'status' => TRUE, 'dependencies' => array(), 'id' => 'new', diff --git a/core/modules/config/src/Tests/ConfigOverridesPriorityTest.php b/core/modules/config/src/Tests/ConfigOverridesPriorityTest.php index 71b3599f97d62640d27ad75e2201a203870aa130..3e6e288d68bebaca312e96f1a5078a252b0130b3 100644 --- a/core/modules/config/src/Tests/ConfigOverridesPriorityTest.php +++ b/core/modules/config/src/Tests/ConfigOverridesPriorityTest.php @@ -56,7 +56,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_translation/src/Access/ConfigTranslationFormAccess.php b/core/modules/config_translation/src/Access/ConfigTranslationFormAccess.php index 09f7fdce705d3bb69175f887a02ad1c49096f347..d7baae3220487937150a63c0407db5708678b2ef 100644 --- a/core/modules/config_translation/src/Access/ConfigTranslationFormAccess.php +++ b/core/modules/config_translation/src/Access/ConfigTranslationFormAccess.php @@ -33,7 +33,7 @@ public function access(Route $route, AccountInterface $account, $langcode = NULL $access = !empty($target_language) && !$target_language->isLocked() && - (empty($this->sourceLanguage) || ($target_language->id != $this->sourceLanguage->id)); + (empty($this->sourceLanguage) || ($target_language->getId() != $this->sourceLanguage->getId())); return $base_access->andIf(AccessResult::allowedIf($access)); } diff --git a/core/modules/config_translation/src/Controller/ConfigTranslationController.php b/core/modules/config_translation/src/Controller/ConfigTranslationController.php index b6b016c9795be2164c340194654d02622f354974..73c87c3c7f48dda5edccce5d9261b2417db852b0 100644 --- a/core/modules/config_translation/src/Controller/ConfigTranslationController.php +++ b/core/modules/config_translation/src/Controller/ConfigTranslationController.php @@ -153,7 +153,7 @@ public function itemPage(Request $request, RouteMatchInterface $route_match, $pl '#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, diff --git a/core/modules/config_translation/src/Form/ConfigTranslationDeleteForm.php b/core/modules/config_translation/src/Form/ConfigTranslationDeleteForm.php index d4c18a40061c95a3d4e36e5022709bf200ff82d0..217d219eee895493f4dfbe6defdfea0c577d2cb4 100644 --- a/core/modules/config_translation/src/Form/ConfigTranslationDeleteForm.php +++ b/core/modules/config_translation/src/Form/ConfigTranslationDeleteForm.php @@ -136,7 +136,7 @@ public function buildForm(array $form, FormStateInterface $form_state, Request $ */ public function submitForm(array &$form, FormStateInterface $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. diff --git a/core/modules/config_translation/src/Form/ConfigTranslationFormBase.php b/core/modules/config_translation/src/Form/ConfigTranslationFormBase.php index d195d240563b731c1ba183b799bebe520a42c66c..fefe5f8a5a963b4899d81f6415203a2db21aa62c 100644 --- a/core/modules/config_translation/src/Form/ConfigTranslationFormBase.php +++ b/core/modules/config_translation/src/Form/ConfigTranslationFormBase.php @@ -215,7 +215,7 @@ public function submitForm(array &$form, FormStateInterface $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)); @@ -311,7 +311,7 @@ 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] ? ('<span lang="' . $this->sourceLanguage->id . '">' . nl2br($base_config_data[$key] . '</span>')) : t('(Empty)'), + '#markup' => $base_config_data[$key] ? ('<span lang="' . $this->sourceLanguage->getId() . '">' . nl2br($base_config_data[$key] . '</span>')) : t('(Empty)'), '#title' => $this->t( '!label <span class="visually-hidden">(!source_language)</span>', array( @@ -377,7 +377,7 @@ protected function setConfig(LanguageInterface $language, Config $base_config, L // 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/src/FormElement/DateFormat.php b/core/modules/config_translation/src/FormElement/DateFormat.php index b19c66ced45e5b46f256863f703269377b66e074..5b19e26d9f305c6285d79cea0db27e6ab9979f2c 100644 --- a/core/modules/config_translation/src/FormElement/DateFormat.php +++ b/core/modules/config_translation/src/FormElement/DateFormat.php @@ -32,7 +32,7 @@ public function getFormElement(DataDefinitionInterface $definition, LanguageInte '#title' => $this->t($definition->getLabel()) . '<span class="visually-hidden"> (' . $language->name . ')</span>', '#description' => $description, '#default_value' => $value, - '#attributes' => array('lang' => $language->id), + '#attributes' => array('lang' => $language->getId()), '#field_suffix' => ' <div class="edit-date-format-suffix"><small id="edit-date-format-suffix">' . $format . '</small></div>', '#ajax' => array( 'callback' => 'Drupal\config_translation\FormElement\DateFormat::ajaxSample', diff --git a/core/modules/config_translation/src/FormElement/Textarea.php b/core/modules/config_translation/src/FormElement/Textarea.php index e4692ec2902cce9f49023c637bf64927bde29518..05b18bb40a28b7ae629a3040e162a6e756ce0122 100644 --- a/core/modules/config_translation/src/FormElement/Textarea.php +++ b/core/modules/config_translation/src/FormElement/Textarea.php @@ -31,7 +31,7 @@ public function getFormElement(DataDefinitionInterface $definition, LanguageInte '#default_value' => $value, '#title' => $this->t($definition->getLabel()) . '<span class="visually-hidden"> (' . $language->name . ')</span>', '#rows' => $rows, - '#attributes' => array('lang' => $language->id), + '#attributes' => array('lang' => $language->getId()), ); } diff --git a/core/modules/config_translation/src/FormElement/Textfield.php b/core/modules/config_translation/src/FormElement/Textfield.php index 34759dc93d7c50a46e44348091d1dd582f5a8571..ccd7cc589f92550223e4a927b866fd65bdb203f1 100644 --- a/core/modules/config_translation/src/FormElement/Textfield.php +++ b/core/modules/config_translation/src/FormElement/Textfield.php @@ -25,7 +25,7 @@ public function getFormElement(DataDefinitionInterface $definition, LanguageInte '#type' => 'textfield', '#default_value' => $value, '#title' => $this->t($definition->getLabel()) . '<span class="visually-hidden"> (' . $language->name . ')</span>', - '#attributes' => array('lang' => $language->id), + '#attributes' => array('lang' => $language->getId()), ); } diff --git a/core/modules/contact/contact.module b/core/modules/contact/contact.module index e9c31812e31496e04092b4a6ec0fb7a64ab6fbeb..f6fc4cda87eb189af9033f9a0860b858b08870ba 100644 --- a/core/modules/contact/contact.module +++ b/core/modules/contact/contact.module @@ -107,14 +107,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('[!form] !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; @@ -133,7 +133,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 emails, 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/src/MessageForm.php b/core/modules/contact/src/MessageForm.php index 698fa8fdd3f1ad2c34888b09ef6e209d26cde36a..0e280cb45acc696143179f59afb0e6a9b497b3fc 100644 --- a/core/modules/contact/src/MessageForm.php +++ b/core/modules/contact/src/MessageForm.php @@ -102,7 +102,7 @@ public function form(array $form, FormStateInterface $form_state) { $form['langcode'] = array( '#title' => $this->t('Language'), '#type' => 'language_select', - '#default_value' => $message->getUntranslated()->language()->id, + '#default_value' => $message->getUntranslated()->language()->getId(), '#languages' => Language::STATE_ALL, '#access' => isset($language_configuration['language_show']) && $language_configuration['language_show'], ); @@ -217,7 +217,7 @@ protected function init(FormStateInterface $form_state) { // set. if ($message->isNew() && !$message->langcode->value) { $language_content = $this->languageManager->getCurrentLanguage(LanguageInterface::TYPE_CONTENT); - $message->langcode->value = $language_content->id; + $message->langcode->value = $language_content->getId(); } parent::init($form_state); diff --git a/core/modules/contact/src/Tests/ContactSitewideTest.php b/core/modules/contact/src/Tests/ContactSitewideTest.php index c1da306751cb284f404afb897c8868b659f578e1..7e6207f0a848620c7789872b0a99ab977d5e25e0 100644 --- a/core/modules/contact/src/Tests/ContactSitewideTest.php +++ b/core/modules/contact/src/Tests/ContactSitewideTest.php @@ -118,7 +118,7 @@ function testSiteWideContact() { // Check that the form was created in site default language. $langcode = \Drupal::config('contact.form.' . $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 form is included in the list of forms. diff --git a/core/modules/content_translation/content_translation.module b/core/modules/content_translation/content_translation.module index f4e61a8bbb828f4f7964113da0c58b917e4d8f86..01f4221e3b098941cc6b53d07d6c51a602b4527f 100644 --- a/core/modules/content_translation/content_translation.module +++ b/core/modules/content_translation/content_translation.module @@ -593,7 +593,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')); } } @@ -749,7 +749,7 @@ function content_translation_page_alter(&$page) { $page['#attached']['html_head_link'][] = array( array( 'rel' => 'alternate', - 'hreflang' => $language->id, + 'hreflang' => $language->getId(), 'href' => $url, ), TRUE, diff --git a/core/modules/content_translation/src/ContentTranslationHandler.php b/core/modules/content_translation/src/ContentTranslationHandler.php index b619036969d63fe8b86d46f8a44c7e775f95e190..90aa1c32e9178a7df203d4313a1c0d7be8b70c81 100644 --- a/core/modules/content_translation/src/ContentTranslationHandler.php +++ b/core/modules/content_translation/src/ContentTranslationHandler.php @@ -50,7 +50,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; @@ -79,7 +79,7 @@ public function getTranslationAccess(EntityInterface $entity, $op) { */ public function getSourceLangcode(FormStateInterface $form_state) { if ($source = $form_state->get(['content_translation', 'source'])) { - return $source->id; + return $source->getId(); } return FALSE; } @@ -90,7 +90,7 @@ public function getSourceLangcode(FormStateInterface $form_state) { public function entityFormAlter(array &$form, FormStateInterface $form_state, EntityInterface $entity) { $form_object = $form_state->getFormObject(); $form_langcode = $form_object->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); @@ -138,8 +138,8 @@ public function entityFormAlter(array &$form, FormStateInterface $form_state, En ), ); foreach (language_list(LanguageInterface::STATE_CONFIGURABLE) as $language) { - if (isset($translations[$language->id])) { - $form['source_langcode']['source']['#options'][$language->id] = $language->name; + if (isset($translations[$language->getId()])) { + $form['source_langcode']['source']['#options'][$language->getId()] = $language->name; } } } @@ -151,8 +151,8 @@ public function entityFormAlter(array &$form, FormStateInterface $form_state, En if ($language_widget && $has_translations) { $form['langcode']['#options'] = array(); foreach (language_list(LanguageInterface::STATE_CONFIGURABLE) as $language) { - if (empty($translations[$language->id]) || $language->id == $entity_langcode) { - $form['langcode']['#options'][$language->id] = $language->name; + if (empty($translations[$language->getId()]) || $language->getId() == $entity_langcode) { + $form['langcode']['#options'][$language->getId()] = $language->name; } } } diff --git a/core/modules/content_translation/src/FieldTranslationSynchronizer.php b/core/modules/content_translation/src/FieldTranslationSynchronizer.php index 6715577fd39af1e8bf6274d36e82c2523f72612e..6b94671b4f903ad056d38b3155156c8e27b929c7 100644 --- a/core/modules/content_translation/src/FieldTranslationSynchronizer.php +++ b/core/modules/content_translation/src/FieldTranslationSynchronizer.php @@ -51,7 +51,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/src/Form/ContentTranslationDeleteForm.php b/core/modules/content_translation/src/Form/ContentTranslationDeleteForm.php index b1a45804b416575450e19f8a4ee2389e34a6bead..9812a1a029beebe99d0ffa6ed49e113400166d92 100644 --- a/core/modules/content_translation/src/Form/ContentTranslationDeleteForm.php +++ b/core/modules/content_translation/src/Form/ContentTranslationDeleteForm.php @@ -73,14 +73,14 @@ public function getCancelUrl() { public function submitForm(array &$form, FormStateInterface $form_state) { // Remove the translated values. $this->entity = $this->entity->getUntranslated(); - $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/src/Tests/ContentTranslationContextualLinksTest.php b/core/modules/content_translation/src/Tests/ContentTranslationContextualLinksTest.php index 7aacd04e5649583dce8c6bdb576f89bbbdfe4194..b8234b31b68381596ede92f2188d13e261f7639f 100644 --- a/core/modules/content_translation/src/Tests/ContentTranslationContextualLinksTest.php +++ b/core/modules/content_translation/src/Tests/ContentTranslationContextualLinksTest.php @@ -64,7 +64,7 @@ class ContentTranslationContextualLinksTest extends WebTestBase { protected function setUp() { parent::setUp(); // Set up an additional language. - $this->langcodes = array(language_default()->id, 'es'); + $this->langcodes = array(language_default()->getId(), 'es'); ConfigurableLanguage::createFromLangcode('es')->save(); // Create a content type. @@ -101,7 +101,7 @@ protected function setUp() { // Enable content translation. $configuration = array( - 'langcode' => language_default()->id, + 'langcode' => language_default()->getId(), 'language_show' => TRUE, ); language_save_default_configuration('node', $this->bundle, $configuration); diff --git a/core/modules/content_translation/src/Tests/ContentTranslationTestBase.php b/core/modules/content_translation/src/Tests/ContentTranslationTestBase.php index 3e14a6a61b25f8494c751221d580abd913d28964..e52036b37fbdf3f851d9bd02c55da6c64e957de4 100644 --- a/core/modules/content_translation/src/Tests/ContentTranslationTestBase.php +++ b/core/modules/content_translation/src/Tests/ContentTranslationTestBase.php @@ -103,7 +103,7 @@ protected function setupLanguages() { foreach ($this->langcodes as $langcode) { ConfigurableLanguage::createFromLangcode($langcode)->save(); } - array_unshift($this->langcodes, \Drupal::languageManager()->getDefaultLanguage()->id); + array_unshift($this->langcodes, \Drupal::languageManager()->getDefaultLanguage()->getId()); } /** diff --git a/core/modules/field/src/Plugin/views/field/Field.php b/core/modules/field/src/Plugin/views/field/Field.php index 7780eff913473528a1b30db34707e3dd880fd5cf..7c14b56bfc344a2631a13888c377fb79b1b4cda3 100644 --- a/core/modules/field/src/Plugin/views/field/Field.php +++ b/core/modules/field/src/Plugin/views/field/Field.php @@ -930,7 +930,7 @@ function field_langcode(EntityInterface $entity) { // 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; } diff --git a/core/modules/field/src/Tests/TranslationTest.php b/core/modules/field/src/Tests/TranslationTest.php index 69621557e6383e2de473ac390c2bee76d5a203ce..841ab3973e5ba669bb32e6e6d8600f96450baf1c 100644 --- a/core/modules/field/src/Tests/TranslationTest.php +++ b/core/modules/field/src/Tests/TranslationTest.php @@ -167,7 +167,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(), $field->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/tests/modules/field_test/field_test.module b/core/modules/field/tests/modules/field_test/field_test.module index 1ee7755bbbe6791ca05b79310c7d202e219fa088..d605ed0a41be40ea31ea136aecf62e613916423d 100644 --- a/core/modules/field/tests/modules/field_test/field_test.module +++ b/core/modules/field/tests/modules/field_test/field_test.module @@ -92,7 +92,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/file/src/Tests/FileTokenReplaceTest.php b/core/modules/file/src/Tests/FileTokenReplaceTest.php index 36fe888cc77babd7829f75a90fb43c2331f1a195..450c77857a6aaa7fabd9457140088a19e8d36993 100644 --- a/core/modules/file/src/Tests/FileTokenReplaceTest.php +++ b/core/modules/file/src/Tests/FileTokenReplaceTest.php @@ -48,10 +48,10 @@ function testFileTokenReplacement() { $tests['[file:mime]'] = String::checkPlain($file->getMimeType()); $tests['[file:size]'] = format_size($file->getSize()); $tests['[file:url]'] = String::checkPlain(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]'] = String::checkPlain(user_format_name($this->admin_user)); $tests['[file:owner:uid]'] = $file->getOwnerId(); @@ -59,7 +59,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))); } @@ -70,7 +70,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/filter/filter.module b/core/modules/filter/filter.module index cfce4fa72327d45b5de10297a70638bb38c684cd..d4a2253f2ccec9c3eac95e85f149805cdd9d0111 100644 --- a/core/modules/filter/filter.module +++ b/core/modules/filter/filter.module @@ -102,13 +102,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, \Drupal::entityManager()->getDefinition('filter_format')->getListCacheTags()); + \Drupal::cache()->set("filter_formats:{$language_interface->getId()}", $formats['all'], Cache::PERMANENT, \Drupal::entityManager()->getDefinition('filter_format')->getListCacheTags()); } } diff --git a/core/modules/filter/src/Tests/FilterCrudTest.php b/core/modules/filter/src/Tests/FilterCrudTest.php index 75bf568ca6ff3453fe1caa4f7fca951fec2d9b63..37d1232c4910691aa5904cd18b4bc54fa0825ad5 100644 --- a/core/modules/filter/src/Tests/FilterCrudTest.php +++ b/core/modules/filter/src/Tests/FilterCrudTest.php @@ -78,7 +78,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/forum/src/Tests/ForumTest.php b/core/modules/forum/src/Tests/ForumTest.php index adbd2a4456df78cc3cf679a276cf8046883af275..8ebdb81a45144e021a53ddc9ce42318da0313f5a 100644 --- a/core/modules/forum/src/Tests/ForumTest.php +++ b/core/modules/forum/src/Tests/ForumTest.php @@ -297,7 +297,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/src/Tests/ForumUninstallTest.php b/core/modules/forum/src/Tests/ForumUninstallTest.php index 388910c97f666233345037f1fe1810aa5afb3da0..eb57a5d2b36f6327f4895d72c17e513d10140847 100644 --- a/core/modules/forum/src/Tests/ForumUninstallTest.php +++ b/core/modules/forum/src/Tests/ForumUninstallTest.php @@ -37,7 +37,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/src/Normalizer/FieldNormalizer.php b/core/modules/hal/src/Normalizer/FieldNormalizer.php index 99a669c590188c6dfc4d482fe8af09f8769104c1..fd2851b5b96c2947e245b683fe08cea935d78187 100644 --- a/core/modules/hal/src/Normalizer/FieldNormalizer.php +++ b/core/modules/hal/src/Normalizer/FieldNormalizer.php @@ -43,8 +43,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 676dfb73adb8c0534e1eb9e451e14a9adc30de6c..55b99201cf85ea025c9b85527ac8eb555f654c95 100644 --- a/core/modules/language/language.module +++ b/core/modules/language/language.module @@ -286,11 +286,11 @@ function language_get_default_langcode($entity_type, $bundle) { $language_interface = \Drupal::languageManager()->getCurrentLanguage(); switch ($configuration['langcode']) { case LanguageInterface::LANGCODE_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': @@ -300,7 +300,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; } @@ -365,7 +365,7 @@ function language_negotiation_url_prefixes_update() { if (empty($prefixes[$language->getId()])) { // For the default language, set the prefix to the empty string, // otherwise use the langcode. - $prefixes[$language->getId()] = $language->isDefault() ? '' : $language->id; + $prefixes[$language->getId()] = $language->isDefault() ? '' : $language->getId(); } // Otherwise we keep the configured prefix. } @@ -495,7 +495,7 @@ function language_form_system_regional_settings_alter(&$form, FormStateInterface $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. <a href="@language-detection">Configure the Selected language</a> setting on the detection and selection page to change the fallback language for language selection.', array('@language-detection' => \Drupal::url('language.negotiation'))), '#weight' => -1, diff --git a/core/modules/language/src/Config/LanguageConfigFactoryOverride.php b/core/modules/language/src/Config/LanguageConfigFactoryOverride.php index 24c4bf5ce85586fd48a89a6aa2481699bdce7dd8..a0fbbfe6cc9f4ff08ecfc9e539a8599b4c7f11c3 100644 --- a/core/modules/language/src/Config/LanguageConfigFactoryOverride.php +++ b/core/modules/language/src/Config/LanguageConfigFactoryOverride.php @@ -116,7 +116,7 @@ public function getStorage($langcode) { * {@inheritdoc} */ public function getCacheSuffix() { - return $this->language ? $this->language->id : NULL; + return $this->language ? $this->language->getId() : NULL; } /** diff --git a/core/modules/language/src/ConfigurableLanguageManager.php b/core/modules/language/src/ConfigurableLanguageManager.php index 9e73d061da43535c780934daaa9162fde056daa7..d6d50756ff39c8951c4f56bde0177e0c8ffce342 100644 --- a/core/modules/language/src/ConfigurableLanguageManager.php +++ b/core/modules/language/src/ConfigurableLanguageManager.php @@ -283,7 +283,7 @@ public function getLanguages($flags = LanguageInterface::STATE_CONFIGURABLE) { // 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 list of languages defined in configuration. $prefix = 'language.entity.'; @@ -296,7 +296,7 @@ public function getLanguages($flags = LanguageInterface::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]->getWeight())); @@ -345,7 +345,7 @@ public function updateLockedLanguageWeights() { // Loop locked languages to maintain the existing order. $locked_languages = $this->getLanguages(LanguageInterface::STATE_LOCKED); - $config_ids = array_map(function($language) { return 'language.entity.' . $language->id; }, $locked_languages); + $config_ids = array_map(function($language) { return 'language.entity.' . $language->getId(); }, $locked_languages); foreach ($this->configFactory->loadMultiple($config_ids) as $config) { // Update system languages weight. $max_weight++; diff --git a/core/modules/language/src/Entity/ConfigurableLanguage.php b/core/modules/language/src/Entity/ConfigurableLanguage.php index f6b0341edb62dc88eaf56bd234857c30e4c6f34f..668a9aa781931e17dadb02d05b96655e7be6685b 100644 --- a/core/modules/language/src/Entity/ConfigurableLanguage.php +++ b/core/modules/language/src/Entity/ConfigurableLanguage.php @@ -50,7 +50,7 @@ class ConfigurableLanguage extends ConfigEntityBase implements ConfigurableLangu * * @var string */ - public $id; + protected $id; /** * The human-readable label for the language. diff --git a/core/modules/language/src/EventSubscriber/LanguageRequestSubscriber.php b/core/modules/language/src/EventSubscriber/LanguageRequestSubscriber.php index c543fc78a0eaac7438f141dffdefcec4d12aea2d..c3218ff6c6f09afcb7133031494e7ad6ba07b099 100644 --- a/core/modules/language/src/EventSubscriber/LanguageRequestSubscriber.php +++ b/core/modules/language/src/EventSubscriber/LanguageRequestSubscriber.php @@ -85,7 +85,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/src/Form/LanguageDeleteForm.php b/core/modules/language/src/Form/LanguageDeleteForm.php index 5b1d2f6ac22d7fa79887dbf611859a913a77e53b..32fb889a5efddb3f61d0e9d5c562152f4d4782c3 100644 --- a/core/modules/language/src/Form/LanguageDeleteForm.php +++ b/core/modules/language/src/Form/LanguageDeleteForm.php @@ -89,7 +89,7 @@ public function buildForm(array $form, FormStateInterface $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/src/Form/LanguageFormBase.php b/core/modules/language/src/Form/LanguageFormBase.php index 59ae4a235572025430d93036f07854c62fa186af..cfb3c3f0adbd792abe4302bb17a248536380e01c 100644 --- a/core/modules/language/src/Form/LanguageFormBase.php +++ b/core/modules/language/src/Form/LanguageFormBase.php @@ -51,7 +51,7 @@ public static function create(ContainerInterface $container) { public function commonForm(array &$form) { /* @var $language \Drupal\language\ConfigurableLanguageInterface */ $language = $this->entity; - if ($language->id()) { + if ($language->getId()) { $form['langcode_view'] = array( '#type' => 'item', '#title' => $this->t('Language code'), diff --git a/core/modules/language/src/Form/NegotiationUrlForm.php b/core/modules/language/src/Form/NegotiationUrlForm.php index eed7a38263b1b4c4d5e373467843deda36a4b989..0b3735f90f649241ce8d39a9ad995a49c63e08f4 100644 --- a/core/modules/language/src/Form/NegotiationUrlForm.php +++ b/core/modules/language/src/Form/NegotiationUrlForm.php @@ -73,7 +73,7 @@ public function buildForm(array $form, FormStateInterface $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->name, '%langcode' => $language->getId()); $form['prefix'][$langcode] = array( '#type' => 'textfield', '#title' => $language->isDefault() ? $this->t('%language (%langcode) path prefix (Default language)', $t_args) : $this->t('%language (%langcode) path prefix', $t_args), @@ -83,7 +83,7 @@ public function buildForm(array $form, FormStateInterface $form_state) { ); $form['domain'][$langcode] = array( '#type' => 'textfield', - '#title' => $this->t('%language (%langcode) domain', array('%language' => $language->name, '%langcode' => $language->id)), + '#title' => $this->t('%language (%langcode) domain', array('%language' => $language->name, '%langcode' => $language->getId())), '#maxlength' => 128, '#default_value' => isset($domains[$langcode]) ? $domains[$langcode] : '', ); diff --git a/core/modules/language/src/LanguageListBuilder.php b/core/modules/language/src/LanguageListBuilder.php index c8dbe137f1ce2f658e0c5410b70c665203fecaba..42ec9d328f8df2cac8badcfcce4bc74970d1d77a 100644 --- a/core/modules/language/src/LanguageListBuilder.php +++ b/core/modules/language/src/LanguageListBuilder.php @@ -50,7 +50,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/src/LanguageNegotiatorInterface.php b/core/modules/language/src/LanguageNegotiatorInterface.php index fa469584b106683aedfb98893be41d1cd4222a83..dc4d1e58a9cbf84416256bc110a33a0f73e45dd4 100644 --- a/core/modules/language/src/LanguageNegotiatorInterface.php +++ b/core/modules/language/src/LanguageNegotiatorInterface.php @@ -90,7 +90,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/src/Plugin/Condition/Language.php b/core/modules/language/src/Plugin/Condition/Language.php index 523c3df1ae205d9327afeca851334842c7346006..07095e17b661ca73d603d657edebd23b0591a679 100644 --- a/core/modules/language/src/Plugin/Condition/Language.php +++ b/core/modules/language/src/Plugin/Condition/Language.php @@ -34,7 +34,7 @@ public function buildConfigurationForm(array $form, FormStateInterface $form_sta $languages = language_list(LanguageInterface::STATE_CONFIGURABLE); $langcodes_options = array(); foreach ($languages as $language) { - $langcodes_options[$language->id] = $language->getName(); + $langcodes_options[$language->getId()] = $language->getName(); } $form['langcodes'] = array( '#type' => 'checkboxes', @@ -71,8 +71,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->name; } return $result; }, array()); @@ -101,7 +101,7 @@ public function evaluate() { $language = $this->getContextValue('language'); // Language visibility settings. - return !empty($this->configuration['langcodes'][$language->id]); + return !empty($this->configuration['langcodes'][$language->getId()]); } /** diff --git a/core/modules/language/src/Plugin/LanguageNegotiation/LanguageNegotiationSession.php b/core/modules/language/src/Plugin/LanguageNegotiation/LanguageNegotiationSession.php index 7f0085d93172133fa2e45ede54c877f89ca6458e..a1547c080a966f55be5db9985b8bf62688055168 100644 --- a/core/modules/language/src/Plugin/LanguageNegotiation/LanguageNegotiationSession.php +++ b/core/modules/language/src/Plugin/LanguageNegotiation/LanguageNegotiationSession.php @@ -72,7 +72,7 @@ public function getLangcode(Request $request = NULL) { public function persist(LanguageInterface $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])) { @@ -126,12 +126,12 @@ public function getLanguageSwitchLinks(Request $request, $type, Url $url) { $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->getNativeLanguages() as $language) { - $langcode = $language->id; + $langcode = $language->getId(); $links[$langcode] = array( 'url' => $url, 'title' => $language->getName(), diff --git a/core/modules/language/src/Plugin/LanguageNegotiation/LanguageNegotiationUI.php b/core/modules/language/src/Plugin/LanguageNegotiation/LanguageNegotiationUI.php index a96dcbdb01e48b9d160e55466613baa0d5f239d0..fd7eb75e751d00b806a4b764fd908df53ec6fc63 100644 --- a/core/modules/language/src/Plugin/LanguageNegotiation/LanguageNegotiationUI.php +++ b/core/modules/language/src/Plugin/LanguageNegotiation/LanguageNegotiationUI.php @@ -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/src/Plugin/LanguageNegotiation/LanguageNegotiationUrl.php b/core/modules/language/src/Plugin/LanguageNegotiation/LanguageNegotiationUrl.php index 0b46727008ddc5c666b825e7bbe2d24800872e08..d84bee48acae13b9688eaf5c5ad88ec355c18885 100644 --- a/core/modules/language/src/Plugin/LanguageNegotiation/LanguageNegotiationUrl.php +++ b/core/modules/language/src/Plugin/LanguageNegotiation/LanguageNegotiationUrl.php @@ -65,14 +65,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; @@ -81,13 +81,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; } } @@ -109,7 +109,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; @@ -136,17 +136,17 @@ public function processOutbound($path, &$options = array(), Request $request = N $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])) { - $options['prefix'] = $config['prefixes'][$options['language']->id] . '/'; + if (is_object($options['language']) && !empty($config['prefixes'][$options['language']->getId()])) { + $options['prefix'] = $config['prefixes'][$options['language']->getId()] . '/'; } } 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. @@ -157,7 +157,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. @@ -192,7 +192,7 @@ public function getLanguageSwitchLinks(Request $request, $type, Url $url) { $links = array(); foreach ($this->languageManager->getNativeLanguages() as $language) { - $links[$language->id] = array( + $links[$language->getId()] = array( 'url' => $url, 'title' => $language->getName(), 'language' => $language, diff --git a/core/modules/language/src/Plugin/LanguageNegotiation/LanguageNegotiationUrlFallback.php b/core/modules/language/src/Plugin/LanguageNegotiation/LanguageNegotiationUrlFallback.php index 6f771e8efc2d9e51156ebd345bf7e3a5e5d5c0e1..abaa6e39051e05fcca6017f793947c327bcc8017 100644 --- a/core/modules/language/src/Plugin/LanguageNegotiation/LanguageNegotiationUrlFallback.php +++ b/core/modules/language/src/Plugin/LanguageNegotiation/LanguageNegotiationUrlFallback.php @@ -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/src/Tests/LanguageConfigurationElementTest.php b/core/modules/language/src/Tests/LanguageConfigurationElementTest.php index f733bf802b7ead76281a4522004a5b6c287ae07e..9b2d82d279128ab2395368b8ad9aa140e218edae 100644 --- a/core/modules/language/src/Tests/LanguageConfigurationElementTest.php +++ b/core/modules/language/src/Tests/LanguageConfigurationElementTest.php @@ -78,7 +78,7 @@ 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(); diff --git a/core/modules/language/src/Tests/LanguageDependencyInjectionTest.php b/core/modules/language/src/Tests/LanguageDependencyInjectionTest.php index 70b0d693c5fa002fa54b44275b48ea5f49f11133..b6fc729339d90335b7d7d22db10fd5ec16be5613 100644 --- a/core/modules/language/src/Tests/LanguageDependencyInjectionTest.php +++ b/core/modules/language/src/Tests/LanguageDependencyInjectionTest.php @@ -48,7 +48,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 { @@ -64,7 +64,7 @@ function testDependencyInjectedNewDefaultLanguage() { entity_delete_multiple('configurable_language', array('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/src/Tests/LanguagePathMonolingualTest.php b/core/modules/language/src/Tests/LanguagePathMonolingualTest.php index d6342e554cc7ca58ec59f054f01589dc43921aed..c574f9177bef25337b2b70bc95e08b502aed2b23 100644 --- a/core/modules/language/src/Tests/LanguagePathMonolingualTest.php +++ b/core/modules/language/src/Tests/LanguagePathMonolingualTest.php @@ -51,7 +51,7 @@ protected 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/src/Tests/LanguageUrlRewritingTest.php b/core/modules/language/src/Tests/LanguageUrlRewritingTest.php index 2876ab6e4a999523a0e68e3cd5c29f9acbf8face..434f864c166c70e40e0f4402f6fabc825e8ac180 100644 --- a/core/modules/language/src/Tests/LanguageUrlRewritingTest.php +++ b/core/modules/language/src/Tests/LanguageUrlRewritingTest.php @@ -85,7 +85,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->randomMachineName(); + $stored_prefix = isset($prefixes[$language->getId()]) ? $prefixes[$language->getId()] : $this->randomMachineName(); if ($this->assertNotEqual($stored_prefix, $prefix, $message1)) { $prefix = $stored_prefix; } diff --git a/core/modules/language/tests/language_test/language_test.module b/core/modules/language/tests/language_test/language_test.module index 6e81581cf54ada7cc49a5e910fc78251f4627022..aeb630e2a76ff46fa59ceee771ad6b3a68b08a99 100644 --- a/core/modules/language/tests/language_test/language_test.module +++ b/core/modules/language/tests/language_test/language_test.module @@ -68,7 +68,7 @@ function language_test_language_negotiation_info_alter(array &$negotiation_info) function language_test_store_language_negotiation() { $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); } diff --git a/core/modules/language/tests/src/Unit/LanguageNegotiationUrlTest.php b/core/modules/language/tests/src/Unit/LanguageNegotiationUrlTest.php index 7f2684bafb946c6fae7496b68cdf21c9317f9527..bf62cf7870fb8aa57cc3bc9c51d95bfe56311a18 100644 --- a/core/modules/language/tests/src/Unit/LanguageNegotiationUrlTest.php +++ b/core/modules/language/tests/src/Unit/LanguageNegotiationUrlTest.php @@ -27,13 +27,17 @@ class LanguageNegotiationUrlTest extends UnitTestCase { protected 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/locale/locale.module b/core/modules/locale/locale.module index e53d79e302f5fb9fa9c6d9f061f5731c55f56051..01ef7814837a371dc1757743f937c65a2fc30915 100644 --- a/core/modules/locale/locale.module +++ b/core/modules/locale/locale.module @@ -295,7 +295,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. @@ -517,11 +517,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); @@ -535,9 +535,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; } @@ -727,16 +727,18 @@ function locale_system_file_system_settings_submit(&$form, FormStateInterface $f * Implements hook_preprocess_HOOK() for node templates. */ function locale_preprocess_node(&$variables) { - if ($variables['node']->language()->id != LanguageInterface::LANGCODE_NOT_SPECIFIED) { - $language_interface = \Drupal::languageManager()->getCurrentLanguage(); + /* @var $node \Drupal\node\NodeInterface */ + $node = $variables['node']; + if ($node->language()->getId() != LanguageInterface::LANGCODE_NOT_SPECIFIED) { + $interface_language = \Drupal::languageManager()->getCurrentLanguage(); - $node_language = $variables['node']->language(); - if ($node_language->id != $language_interface->id) { + $node_language = $node->language(); + if ($node_language->getId() != $interface_language->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->getDirection() != $language_interface->getDirection()) { + $variables['attributes']['lang'] = $node_language->getId(); + if ($node_language->getDirection() != $interface_language->getDirection()) { // If text direction is different form the page's text direction, add // direction information as well. $variables['attributes']['dir'] = $node_language->getDirection(); @@ -1193,7 +1195,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(); @@ -1210,8 +1212,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) . ';'; @@ -1225,23 +1227,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') { @@ -1259,7 +1261,7 @@ function _locale_rebuild_js($langcode = NULL) { } } else { - $locale_javascripts[$language->id] = ''; + $locale_javascripts[$language->getId()] = ''; $status = 'error'; } } @@ -1279,7 +1281,7 @@ function _locale_rebuild_js($langcode = NULL) { return TRUE; case 'rebuilt': - $logger->warning('JavaScript translation file %file.js was lost.', array('%file' => $locale_javascripts[$language->id])); + $logger->warning('JavaScript translation file %file.js was lost.', array('%file' => $locale_javascripts[$language->getId()])); // Proceed to the 'created' case as the JavaScript translation file has // been created again. diff --git a/core/modules/locale/src/Form/ExportForm.php b/core/modules/locale/src/Form/ExportForm.php index 631c4aa8aa4f48ab001e7933c39caaf16754644e..00a4be11026696e0166b7f252653f1a7c8bd6e9e 100644 --- a/core/modules/locale/src/Form/ExportForm.php +++ b/core/modules/locale/src/Form/ExportForm.php @@ -83,7 +83,7 @@ public function buildForm(array $form, FormStateInterface $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' => LanguageInterface::LANGCODE_SYSTEM, ); @@ -140,11 +140,11 @@ public function submitForm(array &$form, FormStateInterface $form_state) { $reader = new PoDatabaseReader(); $language_name = ''; if ($language != NULL) { - $reader->setLangcode($language->id); + $reader->setLangcode($language->getId()); $reader->setOptions($content_options); $languages = $this->languageManager->getLanguages(); - $language_name = isset($languages[$language->id]) ? $languages[$language->id]->name : ''; - $filename = $language->id . '.po'; + $language_name = isset($languages[$language->getId()]) ? $languages[$language->getId()]->name : ''; + $filename = $language->getId() .'.po'; } else { // Template required. diff --git a/core/modules/locale/src/Form/TranslateFormBase.php b/core/modules/locale/src/Form/TranslateFormBase.php index 4599c44c0ffcace99062453889b9428dd8aff2b1..8ff3cd859d3c6ecfa28b3f90849c59c692053634 100644 --- a/core/modules/locale/src/Form/TranslateFormBase.php +++ b/core/modules/locale/src/Form/TranslateFormBase.php @@ -170,7 +170,7 @@ protected function translateFilters() { } // 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/src/LocaleConfigManager.php b/core/modules/locale/src/LocaleConfigManager.php index 73d653cc013a515d4f5934544762e5b405582dc5..e2f44524d4d9478f58197cc6dd403d5f2c44acc0 100644 --- a/core/modules/locale/src/LocaleConfigManager.php +++ b/core/modules/locale/src/LocaleConfigManager.php @@ -326,7 +326,7 @@ public function translateString($name, $langcode, $source, $context) { * A boolean indicating if a language has configuration translations. */ public function hasTranslation($name, LanguageInterface $language) { - $translation = $this->languageManager->getLanguageConfigOverride($language->id, $name); + $translation = $this->languageManager->getLanguageConfigOverride($language->getId(), $name); return !$translation->isNew(); } diff --git a/core/modules/locale/src/Tests/LocalePathTest.php b/core/modules/locale/src/Tests/LocalePathTest.php index ae4b9db93bffa88df985d69c33ecfd74ba32150e..d1678afe025c702f8df70702911198576b3f2c98 100644 --- a/core/modules/locale/src/Tests/LocalePathTest.php +++ b/core/modules/locale/src/Tests/LocalePathTest.php @@ -121,7 +121,7 @@ public function testPathLanguageConfiguration() { $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']); @@ -130,7 +130,7 @@ public function testPathLanguageConfiguration() { $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/src/Tests/LocaleStringTest.php b/core/modules/locale/src/Tests/LocaleStringTest.php index c608d62bf1260824e98e3f64c4287da260883421..430b0244220bb1050cc43d3d6041ae75d75fa18c 100644 --- a/core/modules/locale/src/Tests/LocaleStringTest.php +++ b/core/modules/locale/src/Tests/LocaleStringTest.php @@ -188,8 +188,10 @@ public function buildSourceString($values = array()) { */ public 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 $language_manager \Drupal\Core\Language\LanguageManagerInterface */ + $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/menu_ui/menu_ui.module b/core/modules/menu_ui/menu_ui.module index 0aa49d00f0c80343a8ea7cca5a11ffb815600db4..1669aeacec0e9886f43d7cbdfdb0bc22daabf0f4 100644 --- a/core/modules/menu_ui/menu_ui.module +++ b/core/modules/menu_ui/menu_ui.module @@ -183,7 +183,7 @@ function menu_ui_node_save(EntityInterface $node) { 'parent' => $definition['parent'], 'weight' => isset($definition['weight']) ? $definition['weight'] : 0, 'enabled' => 1, - 'langcode' => $node->getUntranslated()->language()->id, + 'langcode' => $node->getUntranslated()->language()->getId(), )); } if (!$entity->save()) { diff --git a/core/modules/migrate_drupal/src/Tests/d6/MigrateAggregatorFeedTest.php b/core/modules/migrate_drupal/src/Tests/d6/MigrateAggregatorFeedTest.php index b8eab067b875bcb5090bb751f83486767303da4a..b8b503e99aeaeba443f4cf6ba5399fe5629155b2 100644 --- a/core/modules/migrate_drupal/src/Tests/d6/MigrateAggregatorFeedTest.php +++ b/core/modules/migrate_drupal/src/Tests/d6/MigrateAggregatorFeedTest.php @@ -42,7 +42,7 @@ public function testAggregatorFeedImport() { $feed = Feed::load(5); $this->assertNotNull($feed->uuid()); $this->assertEqual($feed->title->value, 'Know Your Meme'); - $this->assertEqual($feed->language()->id, 'en'); + $this->assertEqual($feed->language()->getId(), 'en'); $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/src/Tests/d6/MigrateAggregatorItemTest.php b/core/modules/migrate_drupal/src/Tests/d6/MigrateAggregatorItemTest.php index 0b5a349a57b4a65fbc01238eac77260dfb51d51d..93f189403bfb9f8d1f93004fc22e55482c87d533 100644 --- a/core/modules/migrate_drupal/src/Tests/d6/MigrateAggregatorItemTest.php +++ b/core/modules/migrate_drupal/src/Tests/d6/MigrateAggregatorItemTest.php @@ -67,7 +67,7 @@ public function testAggregatorItem() { $this->assertEqual($item->getDescription(), "<h2 id='new'>What's new with Drupal 8?</h2>"); $this->assertEqual($item->getLink(), 'https://groups.drupal.org/node/395218'); $this->assertEqual($item->getPostedTime(), 1389297196); - $this->assertEqual($item->language()->id, 'en'); + $this->assertEqual($item->language()->getId(), 'en'); $this->assertEqual($item->getGuid(), '395218 at https://groups.drupal.org'); } diff --git a/core/modules/migrate_drupal/src/Tests/d6/MigrateBlockContentTest.php b/core/modules/migrate_drupal/src/Tests/d6/MigrateBlockContentTest.php index 083565024e310ea16ae060e94d78d58a272172a1..9894bddfa83ad2fbc277caa33f3968d0d8f053b0 100644 --- a/core/modules/migrate_drupal/src/Tests/d6/MigrateBlockContentTest.php +++ b/core/modules/migrate_drupal/src/Tests/d6/MigrateBlockContentTest.php @@ -51,7 +51,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('en', $block->language()->id); + $this->assertEqual('en', $block->language()->getId()); $this->assertEqual('<h3>My first custom block body</h3>', $block->body->value); $this->assertEqual('full_html', $block->body->format); @@ -59,7 +59,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('en', $block->language()->id); + $this->assertEqual('en', $block->language()->getId()); $this->assertEqual('<h3>My second custom block body</h3>', $block->body->value); $this->assertEqual('full_html', $block->body->format); } diff --git a/core/modules/migrate_drupal/src/Tests/d6/MigrateCommentTest.php b/core/modules/migrate_drupal/src/Tests/d6/MigrateCommentTest.php index 77980cd8d9228da4ed7d8aa1f5313062546e4887..82066182abe957e4ca46c24489956428b433bbfa 100644 --- a/core/modules/migrate_drupal/src/Tests/d6/MigrateCommentTest.php +++ b/core/modules/migrate_drupal/src/Tests/d6/MigrateCommentTest.php @@ -81,7 +81,7 @@ public function testComments() { $this->assertEqual(0, $comment->pid->target_id); $this->assertEqual(1, $comment->getCommentedEntityId()); $this->assertEqual('node', $comment->getCommentedEntityTypeId()); - $this->assertEqual('en', $comment->language()->id); + $this->assertEqual('en', $comment->language()->getId()); $this->assertEqual('comment_no_subject', $comment->getTypeId()); $comment = entity_load('comment', 2); diff --git a/core/modules/node/node.tokens.inc b/core/modules/node/node.tokens.inc index 7109d308b4ebb1f9508eeed0bb751744359ac5c1..33461c91e6f90701de9f4b58f7a5afbd7b38b47a 100644 --- a/core/modules/node/node.tokens.inc +++ b/core/modules/node/node.tokens.inc @@ -161,7 +161,7 @@ function node_tokens($type, $tokens, array $data = array(), array $options = arr break; case 'langcode': - $replacements[$original] = $sanitize ? String::checkPlain($node->language()->id) : $node->language()->id; + $replacements[$original] = $sanitize ? String::checkPlain($node->language()->getId()) : $node->language()->getId(); break; case 'url': diff --git a/core/modules/node/src/Access/NodeRevisionAccessCheck.php b/core/modules/node/src/Access/NodeRevisionAccessCheck.php index 0fdc11530ed944b32845ce203b873b2bc30e7eb0..f7309d739777941f8fa3fb38bb4e7629bee8210f 100644 --- a/core/modules/node/src/Access/NodeRevisionAccessCheck.php +++ b/core/modules/node/src/Access/NodeRevisionAccessCheck.php @@ -128,7 +128,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/src/Entity/Node.php b/core/modules/node/src/Entity/Node.php index b5bb8f83e0b633052141184f774909f870d5b968..59481033f3ea21fc983233d5b33c59e4a1efa9dd 100644 --- a/core/modules/node/src/Entity/Node.php +++ b/core/modules/node/src/Entity/Node.php @@ -160,14 +160,14 @@ public function access($operation = 'view', AccountInterface $account = NULL, $r * {@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(LanguageInterface::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/src/NodeForm.php b/core/modules/node/src/NodeForm.php index a214282434fb99c340637177ac06ae83685048db..7f9ef847c78649957aeba308ddfd45fb8769f29a 100644 --- a/core/modules/node/src/NodeForm.php +++ b/core/modules/node/src/NodeForm.php @@ -112,7 +112,7 @@ public function form(array $form, FormStateInterface $form_state) { $form['langcode'] = array( '#title' => t('Language'), '#type' => 'language_select', - '#default_value' => $node->getUntranslated()->language()->id, + '#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/src/NodeGrantDatabaseStorage.php b/core/modules/node/src/NodeGrantDatabaseStorage.php index 7ea330781fca686a7658a2696e02bd055a71dafd..9cddb2e7f5da9a3ced81c35f50c0f8b87c03d6ad 100644 --- a/core/modules/node/src/NodeGrantDatabaseStorage.php +++ b/core/modules/node/src/NodeGrantDatabaseStorage.php @@ -202,7 +202,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/src/NodeListBuilder.php b/core/modules/node/src/NodeListBuilder.php index 606da79b6a1ed1f2153824411d8eecfe8fbe86cd..f2011c0244ddcff737110b22ec16b9cfecb2b042 100644 --- a/core/modules/node/src/NodeListBuilder.php +++ b/core/modules/node/src/NodeListBuilder.php @@ -96,7 +96,7 @@ 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 != LanguageInterface::LANGCODE_NOT_SPECIFIED && isset($languages[$langcode]) ? array('language' => $languages[$langcode]) : array()); diff --git a/core/modules/node/src/NodeStorage.php b/core/modules/node/src/NodeStorage.php index f851c942563f4e2967683071201203de74eb34d3..f3c97e4d90f28fd36fced1fe5c2d50cf3f7acfc9 100644 --- a/core/modules/node/src/NodeStorage.php +++ b/core/modules/node/src/NodeStorage.php @@ -55,7 +55,7 @@ public function updateType($old_type, $new_type) { public function clearRevisionsLanguage($language) { return $this->database->update('node_revision') ->fields(array('langcode' => LanguageInterface::LANGCODE_NOT_SPECIFIED)) - ->condition('langcode', $language->id) + ->condition('langcode', $language->getId()) ->execute(); } diff --git a/core/modules/node/src/Plugin/Search/NodeSearch.php b/core/modules/node/src/Plugin/Search/NodeSearch.php index 5d13e7dd23e8a47cf87927b7a796c0d048820501..c5ad9909ce47a9e19b0ffe00275e7e17a3208fdb 100644 --- a/core/modules/node/src/Plugin/Search/NodeSearch.php +++ b/core/modules/node/src/Plugin/Search/NodeSearch.php @@ -282,7 +282,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; @@ -342,23 +342,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 = '<h1>' . String::checkPlain($node->label($language->id)) . '</h1>' . $node->rendered; + $text = '<h1>' . String::checkPlain($node->label($language->getId())) . '</h1>' . $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()); } } diff --git a/core/modules/node/src/Tests/NodeAccessLanguageTest.php b/core/modules/node/src/Tests/NodeAccessLanguageTest.php index aa29d40610f3183eb0e383d0c7bf3cf20251f7fc..c97dc071fbd2c25c11f0bed91a0fdbc661d4cdb2 100644 --- a/core/modules/node/src/Tests/NodeAccessLanguageTest.php +++ b/core/modules/node/src/Tests/NodeAccessLanguageTest.php @@ -54,7 +54,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); @@ -74,7 +74,7 @@ function testNodeAccess() { 'private' => FALSE, 'langcode' => LanguageInterface::LANGCODE_NOT_SPECIFIED, )); - $this->assertTrue($node_public_no_language->language()->id == LanguageInterface::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); @@ -92,7 +92,7 @@ function testNodeAccess() { \Drupal::entityManager()->getAccessControlHandler('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); @@ -147,7 +147,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); @@ -167,7 +167,7 @@ function testNodeAccessPrivate() { 'private' => TRUE, 'langcode' => LanguageInterface::LANGCODE_NOT_SPECIFIED, )); - $this->assertTrue($node_private_no_language->language()->id == LanguageInterface::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); @@ -198,7 +198,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'); @@ -230,12 +230,12 @@ 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. @@ -243,7 +243,7 @@ function testNodeAccessQueryTag() { 'private' => FALSE, 'langcode' => LanguageInterface::LANGCODE_NOT_SPECIFIED, )); - $this->assertTrue($node_no_language->language()->id == LanguageInterface::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/src/Tests/NodeFieldMultilingualTest.php b/core/modules/node/src/Tests/NodeFieldMultilingualTest.php index 8649a35e337e9b30c4e15d328e17e9081e8655f1..d00ffcdba3a7b0603882ac8d8ef12187332c005e 100644 --- a/core/modules/node/src/Tests/NodeFieldMultilingualTest.php +++ b/core/modules/node/src/Tests/NodeFieldMultilingualTest.php @@ -77,7 +77,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'; @@ -89,7 +89,7 @@ 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(LanguageInterface::TYPE_CONTENT, array(LanguageNegotiationUrl::METHOD_ID => 0)); diff --git a/core/modules/node/src/Tests/NodeLastChangedTest.php b/core/modules/node/src/Tests/NodeLastChangedTest.php index 16ea74c5641c23664d964602e7322e1de4b1f056..ae5dc2710b7e427b935b00d37bb42c9baaeb7819 100644 --- a/core/modules/node/src/Tests/NodeLastChangedTest.php +++ b/core/modules/node/src/Tests/NodeLastChangedTest.php @@ -40,7 +40,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/src/Tests/NodeTokenReplaceTest.php b/core/modules/node/src/Tests/NodeTokenReplaceTest.php index 98d1e9b623a5330c8e3d9cd77855383945d53c53..81038664a01947a0b06df5d42f88ba6da06a3781 100644 --- a/core/modules/node/src/Tests/NodeTokenReplaceTest.php +++ b/core/modules/node/src/Tests/NodeTokenReplaceTest.php @@ -68,20 +68,20 @@ function testNodeTokenReplacement() { $tests['[node:title]'] = String::checkPlain($node->getTitle()); $tests['[node:body]'] = $node->body->processed; $tests['[node:summary]'] = $node->body->summary_processed; - $tests['[node:langcode]'] = String::checkPlain($node->language()->id); + $tests['[node:langcode]'] = String::checkPlain($node->language()->getId()); $tests['[node:url]'] = $node->url('canonical', $url_options); $tests['[node:edit-url]'] = $node->url('edit-form', $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.formatter')->formatInterval(REQUEST_TIME - $node->getCreatedTime(), 2, $this->interfaceLanguage->id); - $tests['[node:changed:since]'] = \Drupal::service('date.formatter')->formatInterval(REQUEST_TIME - $node->getChangedTime(), 2, $this->interfaceLanguage->id); + $tests['[node:created:since]'] = \Drupal::service('date.formatter')->formatInterval(REQUEST_TIME - $node->getCreatedTime(), 2, $this->interfaceLanguage->getId()); + $tests['[node:changed:since]'] = \Drupal::service('date.formatter')->formatInterval(REQUEST_TIME - $node->getChangedTime(), 2, $this->interfaceLanguage->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.'); foreach ($tests as $input => $expected) { - $output = $this->tokenService->replace($input, array('node' => $node), array('langcode' => $this->interfaceLanguage->id)); + $output = $this->tokenService->replace($input, array('node' => $node), array('langcode' => $this->interfaceLanguage->getId())); $this->assertEqual($output, $expected, format_string('Sanitized node token %token replaced.', array('%token' => $input))); } @@ -89,11 +89,11 @@ 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) { - $output = $this->tokenService->replace($input, array('node' => $node), array('langcode' => $this->interfaceLanguage->id, 'sanitize' => FALSE)); + $output = $this->tokenService->replace($input, array('node' => $node), array('langcode' => $this->interfaceLanguage->getId(), 'sanitize' => FALSE)); $this->assertEqual($output, $expected, format_string('Unsanitized node token %token replaced.', array('%token' => $input))); } diff --git a/core/modules/search/search.pages.inc b/core/modules/search/search.pages.inc index 6590b90853aa10b2cec55af50f71aad42aecc3ba..4c84c84666d1c5bcd8f05c497b5c861548aeaa58 100644 --- a/core/modules/search/search.pages.inc +++ b/core/modules/search/search.pages.inc @@ -37,7 +37,7 @@ function template_preprocess_search_result(&$variables) { $result = $variables['result']; $variables['url'] = check_url($result['link']); $variables['title'] = String::checkPlain($result['title']); - if (isset($result['language']) && $result['language'] != $language_interface->id && $result['language'] != LanguageInterface::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/shortcut/src/ShortcutForm.php b/core/modules/shortcut/src/ShortcutForm.php index c9f5d3daecf556875ec7c92717fa16de0a0e565a..86c022efdf79bbd52450857001251e29b7bb42fd 100644 --- a/core/modules/shortcut/src/ShortcutForm.php +++ b/core/modules/shortcut/src/ShortcutForm.php @@ -72,7 +72,7 @@ public function form(array $form, FormStateInterface $form_state) { $form['langcode'] = array( '#title' => t('Language'), '#type' => 'language_select', - '#default_value' => $this->entity->getUntranslated()->language()->id, + '#default_value' => $this->entity->getUntranslated()->language()->getId(), '#languages' => LanguageInterface::STATE_ALL, ); diff --git a/core/modules/statistics/src/Tests/StatisticsTokenReplaceTest.php b/core/modules/statistics/src/Tests/StatisticsTokenReplaceTest.php index 05b6aab982e53b1a98729877d307a16f34ec59c8..d481f0141da0776c6c0bf1a9c778619c7f8d3554 100644 --- a/core/modules/statistics/src/Tests/StatisticsTokenReplaceTest.php +++ b/core/modules/statistics/src/Tests/StatisticsTokenReplaceTest.php @@ -49,7 +49,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 a863baa91050a7aa79c3f9afff42bcf211c65b94..3edb6c4c89a11d55779f2ea1adaa94885fe716ed 100644 --- a/core/modules/system/core.api.php +++ b/core/modules/system/core.api.php @@ -356,7 +356,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/entity.api.php b/core/modules/system/entity.api.php index 534b7b88019a3c99861c3db8afab0052fe31a45f..5974440d70ebc5c45987d77cc10da5d1ba33f63b 100644 --- a/core/modules/system/entity.api.php +++ b/core/modules/system/entity.api.php @@ -186,7 +186,7 @@ * To make a render array for a loaded entity: * @code * // You can omit the language ID if the default language is being used. - * $build = $view_builder->view($entity, 'view_mode_name', $language->id); + * $build = $view_builder->view($entity, 'view_mode_name', $language->getId()); * @endcode * You can also use the viewMultiple() method to view multiple entities. * @@ -469,7 +469,7 @@ * Then, to build and render the entity: * @code * // You can omit the language ID if the default language is being used. - * $build = $view_builder->view($entity, 'view_mode_name', $language->id); + * $build = $view_builder->view($entity, 'view_mode_name', $language->getId()); * // $build is a render array. * $rendered = drupal_render($build); * @endcode @@ -893,7 +893,7 @@ function hook_ENTITY_TYPE_storage_load(array $entities) { function hook_entity_presave(Drupal\Core\Entity\EntityInterface $entity) { if ($entity instanceof ContentEntityInterface && $entity->isTranslatable()) { $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')); } } @@ -909,7 +909,7 @@ function hook_entity_presave(Drupal\Core\Entity\EntityInterface $entity) { function hook_ENTITY_TYPE_presave(Drupal\Core\Entity\EntityInterface $entity) { if ($entity->isTranslatable()) { $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')); } } diff --git a/core/modules/system/language.api.php b/core/modules/system/language.api.php index f52e22dd3f2c20678e04fc8cf814afcfd0db0caa..d0ab879abc78b6c6fed644aa7ec753f276c17b63 100644 --- a/core/modules/system/language.api.php +++ b/core/modules/system/language.api.php @@ -108,8 +108,8 @@ function hook_language_switch_links_alter(array &$links, $type, $path) { $language_interface = \Drupal::languageManager()->getCurrentLanguage(); - if ($type == LanguageInterface::TYPE_CONTENT && isset($links[$language_interface->id])) { - foreach ($links[$language_interface->id] as $link) { + if ($type == LanguageInterface::TYPE_CONTENT && isset($links[$language_interface->getId()])) { + foreach ($links[$language_interface->getId()] as $link) { $link['attributes']['class'][] = 'active-language'; } } @@ -150,7 +150,7 @@ function hook_language_switch_links_alter(array &$links, $type, $path) { * Here is a code snippet to transliterate some text: * @code * // Use the current default interface language. - * $langcode = \Drupal::languageManager()->getCurrentLanguage()->id; + * $langcode = \Drupal::languageManager()->getCurrentLanguage()->getId(); * // Instantiate the transliteration class. * $trans = \Drupal::transliteration(); * // Use this to transliterate some text. diff --git a/core/modules/system/src/Tests/Common/UrlTest.php b/core/modules/system/src/Tests/Common/UrlTest.php index e316eaa6fbc86a7debd6653aa69ccba22d680e7b..e01a7da0c5497afea67c519063cb2c8dd29b01ae 100644 --- a/core/modules/system/src/Tests/Common/UrlTest.php +++ b/core/modules/system/src/Tests/Common/UrlTest.php @@ -59,7 +59,7 @@ function testLinkAttributes() { '#url' => Url::fromUri('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/src/Tests/Entity/EntityFieldDefaultValueTest.php b/core/modules/system/src/Tests/Entity/EntityFieldDefaultValueTest.php index cd7f237078a9096bd39aa546d916860ca15ccb56..a44f5090a2e1c4465be0e4a50375803960da9822 100644 --- a/core/modules/system/src/Tests/Entity/EntityFieldDefaultValueTest.php +++ b/core/modules/system/src/Tests/Entity/EntityFieldDefaultValueTest.php @@ -61,7 +61,7 @@ public function testDefaultValueCallback() { $entity = $this->entityManager->getStorage('entity_test_default_value')->create(); // The description field has a default value callback for testing, see // entity_test_field_default_value(). - $this->assertEqual($entity->description->value, 'description_' . $entity->language()->id); + $this->assertEqual($entity->description->value, 'description_' . $entity->language()->getId()); } } diff --git a/core/modules/system/src/Tests/Entity/EntityFieldTest.php b/core/modules/system/src/Tests/Entity/EntityFieldTest.php index e17ab7025615c95c3e9a3810428e45cfdd8aed2b..bdd7937913c58e35807922e2b5210631396e55dc 100644 --- a/core/modules/system/src/Tests/Entity/EntityFieldTest.php +++ b/core/modules/system/src/Tests/Entity/EntityFieldTest.php @@ -200,14 +200,14 @@ protected function assertReadWrite($entity_type) { $this->assertEqual(\Drupal::languageManager()->getLanguage($langcode), $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 = $langcode; $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. diff --git a/core/modules/system/src/Tests/Entity/EntityLanguageTestBase.php b/core/modules/system/src/Tests/Entity/EntityLanguageTestBase.php index ca5d29e53403e8eae756d7886c5a338587eebbd8..28c4f713eae103c9cbb1c4c357515d3f6c4624e5 100644 --- a/core/modules/system/src/Tests/Entity/EntityLanguageTestBase.php +++ b/core/modules/system/src/Tests/Entity/EntityLanguageTestBase.php @@ -109,7 +109,7 @@ protected function setUp() { 'label' => $this->randomString(), 'weight' => $i, )); - $this->langcodes[$i] = $language->id(); + $this->langcodes[$i] = $language->getId(); $language->save(); } } diff --git a/core/modules/system/src/Tests/Entity/EntityTranslationFormTest.php b/core/modules/system/src/Tests/Entity/EntityTranslationFormTest.php index 53ad96bf762b03a69df54efe7e390fa39c6dc065..59da34d0528741f2ce456eee690fc35980189a37 100644 --- a/core/modules/system/src/Tests/Entity/EntityTranslationFormTest.php +++ b/core/modules/system/src/Tests/Entity/EntityTranslationFormTest.php @@ -64,12 +64,12 @@ function testEntityFormLanguage() { $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'); - $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]; diff --git a/core/modules/system/src/Tests/Entity/EntityTranslationTest.php b/core/modules/system/src/Tests/Entity/EntityTranslationTest.php index efb96c76cedea003cfee5bf13f4fe24dbd77c861..6d6b4a3f330a91108d8dae53f1d2af0f50ae28b8 100644 --- a/core/modules/system/src/Tests/Entity/EntityTranslationTest.php +++ b/core/modules/system/src/Tests/Entity/EntityTranslationTest.php @@ -39,7 +39,7 @@ protected function _testEntityLanguageMethods($entity_type) { 'name' => 'test', 'user_id' => $this->container->get('current_user')->id(), )); - $this->assertEqual($entity->language()->getId(), $this->languageManager->getDefaultLanguage()->id, format_string('%entity_type: Entity created with API has default language.', array('%entity_type' => $entity_type))); + $this->assertEqual($entity->language()->getId(), $this->languageManager->getDefaultLanguage()->getId(), format_string('%entity_type: Entity created with API has default language.', array('%entity_type' => $entity_type))); $entity = entity_create($entity_type, array( 'name' => 'test', 'user_id' => \Drupal::currentUser()->id(), @@ -153,7 +153,7 @@ protected function _testMultilingualProperties($entity_type) { $entity = entity_create($entity_type, array('name' => $name, 'user_id' => $uid, 'langcode' => LanguageInterface::LANGCODE_NOT_SPECIFIED)); $entity->save(); $entity = entity_load($entity_type, $entity->id()); - $default_langcode = $entity->language()->id; + $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))); @@ -173,7 +173,7 @@ 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))); @@ -222,7 +222,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)); } @@ -322,8 +322,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; @@ -337,16 +337,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.'); @@ -450,7 +450,7 @@ function testEntityTranslationAPI() { * Tests language fallback applied to field and entity translations. */ function testLanguageFallback() { - $current_langcode = $this->languageManager->getCurrentLanguage(LanguageInterface::TYPE_CONTENT)->id; + $current_langcode = $this->languageManager->getCurrentLanguage(LanguageInterface::TYPE_CONTENT)->getId(); $this->langcodes[] = $current_langcode; $values = array(); @@ -474,7 +474,7 @@ 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(); @@ -482,14 +482,14 @@ function testLanguageFallback() { $language->set('weight', -1); $language->save(); $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/src/Tests/Entity/FieldSqlStorageTest.php b/core/modules/system/src/Tests/Entity/FieldSqlStorageTest.php index 037d7077521b0ae9c04865763d5bddac85ca0df5..6d487bea8c4dfa10ac0ac4b0f473efac6100c273 100644 --- a/core/modules/system/src/Tests/Entity/FieldSqlStorageTest.php +++ b/core/modules/system/src/Tests/Entity/FieldSqlStorageTest.php @@ -131,13 +131,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(); @@ -201,7 +201,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'], ); @@ -224,7 +224,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'], ); @@ -252,7 +252,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/src/Tests/Entity/FieldTranslationSqlStorageTest.php b/core/modules/system/src/Tests/Entity/FieldTranslationSqlStorageTest.php index 4222b8f6d9132204ae486d85334bbfcbb29cb205..68c50637570b485c37d6f4501ba7e0b28a43124c 100644 --- a/core/modules/system/src/Tests/Entity/FieldTranslationSqlStorageTest.php +++ b/core/modules/system/src/Tests/Entity/FieldTranslationSqlStorageTest.php @@ -80,7 +80,7 @@ protected function assertFieldStorageLangcode(FieldableEntityInterface $entity, $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); /** @var \Drupal\Core\Entity\Sql\DefaultTableMapping $table_mapping */ $table_mapping = \Drupal::entityManager()->getStorage($entity_type)->getTableMapping(); diff --git a/core/modules/system/src/Tests/KeyValueStore/KeyValueContentEntityStorageTest.php b/core/modules/system/src/Tests/KeyValueStore/KeyValueContentEntityStorageTest.php index 721b8d317042a2c379bad0d02d3a12610bf529fc..679fe71b55f7ffa46bcf26598642137afe00b202 100644 --- a/core/modules/system/src/Tests/KeyValueStore/KeyValueContentEntityStorageTest.php +++ b/core/modules/system/src/Tests/KeyValueStore/KeyValueContentEntityStorageTest.php @@ -37,7 +37,7 @@ protected function setUp() { * 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/src/Tests/Mail/MailTest.php b/core/modules/system/src/Tests/Mail/MailTest.php index a4dcf5f83336926c41f2e7a96d5e91d080283031..78ebf249814644eec8dd04c0195d8de3bb249896 100644 --- a/core/modules/system/src/Tests/Mail/MailTest.php +++ b/core/modules/system/src/Tests/Mail/MailTest.php @@ -60,7 +60,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/src/Tests/System/TokenReplaceUnitTest.php b/core/modules/system/src/Tests/System/TokenReplaceUnitTest.php index eaed0a6712d038cc49181a8c2684531b23652666..c5123644f463bb0ad49004756d55eef1d6e1075b 100644 --- a/core/modules/system/src/Tests/System/TokenReplaceUnitTest.php +++ b/core/modules/system/src/Tests/System/TokenReplaceUnitTest.php @@ -40,7 +40,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->interfaceLanguage->id)); + $output = $this->tokenService->replace($input, array(), array('langcode' => $this->interfaceLanguage->getId())); $this->assertTrue($output == $expected, format_string('Token recognized in string %string', array('%string' => $input))); } @@ -61,12 +61,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->interfaceLanguage->id, 'clear' => TRUE)); + $result = $this->tokenService->replace($source, array(), array('langcode' => $this->interfaceLanguage->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->interfaceLanguage->id)); + $result = $this->tokenService->replace($source, array(), array('langcode' => $this->interfaceLanguage->getId())); $this->assertEqual($target, $result, 'Valid tokens replaced while invalid tokens ignored.'); } @@ -106,7 +106,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->interfaceLanguage->id)); + $output = $this->tokenService->replace($input, array(), array('langcode' => $this->interfaceLanguage->getId())); $this->assertEqual($output, $expected, format_string('Sanitized system site information token %token replaced.', array('%token' => $input))); } @@ -115,7 +115,7 @@ public function testSystemSiteTokenReplacement() { $tests['[site:slogan]'] = $config->get('slogan'); foreach ($tests as $input => $expected) { - $output = $this->tokenService->replace($input, array(), array('langcode' => $this->interfaceLanguage->id, 'sanitize' => FALSE)); + $output = $this->tokenService->replace($input, array(), array('langcode' => $this->interfaceLanguage->getId(), 'sanitize' => FALSE)); $this->assertEqual($output, $expected, format_string('Unsanitized system site information token %token replaced.', array('%token' => $input))); } @@ -141,18 +141,18 @@ public function testSystemDateTokenReplacement() { // Generate and test tokens. $tests = array(); $date_formatter = \Drupal::service('date.formatter'); - $tests['[date:short]'] = $date_formatter->format($date, 'short', '', NULL, $this->interfaceLanguage->id); - $tests['[date:medium]'] = $date_formatter->format($date, 'medium', '', NULL, $this->interfaceLanguage->id); - $tests['[date:long]'] = $date_formatter->format($date, 'long', '', NULL, $this->interfaceLanguage->id); - $tests['[date:custom:m/j/Y]'] = $date_formatter->format($date, 'custom', 'm/j/Y', NULL, $this->interfaceLanguage->id); - $tests['[date:since]'] = $date_formatter->formatInterval(REQUEST_TIME - $date, 2, $this->interfaceLanguage->id); + $tests['[date:short]'] = $date_formatter->format($date, 'short', '', NULL, $this->interfaceLanguage->getId()); + $tests['[date:medium]'] = $date_formatter->format($date, 'medium', '', NULL, $this->interfaceLanguage->getId()); + $tests['[date:long]'] = $date_formatter->format($date, 'long', '', NULL, $this->interfaceLanguage->getId()); + $tests['[date:custom:m/j/Y]'] = $date_formatter->format($date, 'custom', 'm/j/Y', NULL, $this->interfaceLanguage->getId()); + $tests['[date:since]'] = $date_formatter->formatInterval(REQUEST_TIME - $date, 2, $this->interfaceLanguage->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->interfaceLanguage->id)); + $output = $this->tokenService->replace($input, array('date' => $date), array('langcode' => $this->interfaceLanguage->getId())); $this->assertEqual($output, $expected, format_string('Date token %token replaced.', array('%token' => $input))); } } diff --git a/core/modules/system/src/Tests/Theme/TwigTransTest.php b/core/modules/system/src/Tests/Theme/TwigTransTest.php index 942a6dc5b6e2643d77e82c09cb7fdeaf273a93b1..956e7be14482caf070a1482e4b1027809263132c 100644 --- a/core/modules/system/src/Tests/Theme/TwigTransTest.php +++ b/core/modules/system/src/Tests/Theme/TwigTransTest.php @@ -74,7 +74,7 @@ protected function setUp() { $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.module b/core/modules/system/system.module index 1c930f7b2c4663a896be53c7ab67d1c2c81cbb8e..26a6e902cad9f5745a2f30d609f94240737cfe94 100644 --- a/core/modules/system/system.module +++ b/core/modules/system/system.module @@ -569,7 +569,7 @@ function system_page_build(&$page) { array( 'path' => current_path(), 'front' => drupal_is_front_page(), - 'language' => \Drupal::languageManager()->getCurrentLanguage(LanguageInterface::TYPE_URL)->id, + 'language' => \Drupal::languageManager()->getCurrentLanguage(LanguageInterface::TYPE_URL)->getId(), 'query' => \Drupal::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 41906a18b64689258e3df61e90f120490c17f316..12950bc9c3f39a0fb8a11e33f1cc5843afc250c2 100644 --- a/core/modules/system/tests/modules/entity_test/entity_test.module +++ b/core/modules/system/tests/modules/entity_test/entity_test.module @@ -404,28 +404,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()); } /** @@ -443,7 +443,7 @@ function entity_test_entity_test_mul_translation_delete(EntityInterface $transla * @see \Drupal\field\Entity\FieldConfig::$default_value */ function entity_test_field_default_value(FieldableEntityInterface $entity, FieldDefinitionInterface $definition) { - return array(array('value' => $definition->getName() . '_' . $entity->language()->id)); + return array(array('value' => $definition->getName() . '_' . $entity->language()->getId())); } /** diff --git a/core/modules/system/tests/modules/entity_test/src/EntityTestForm.php b/core/modules/system/tests/modules/entity_test/src/EntityTestForm.php index 1db41d4edda55340b2eacb0a555da68b7e437579..8a60fef02e17d5e2a0e7128613784f7cd6fa53cc 100644 --- a/core/modules/system/tests/modules/entity_test/src/EntityTestForm.php +++ b/core/modules/system/tests/modules/entity_test/src/EntityTestForm.php @@ -38,7 +38,7 @@ public function form(array $form, FormStateInterface $form_state) { $form['langcode'] = array( '#title' => t('Language'), '#type' => 'language_select', - '#default_value' => $entity->getUntranslated()->language()->id, + '#default_value' => $entity->getUntranslated()->language()->getId(), '#languages' => LanguageInterface::STATE_ALL, ); diff --git a/core/modules/system/theme.api.php b/core/modules/system/theme.api.php index f74af95c0967403c7525e8bc091403aac3d83362..2e41d6a240dd9536ab7de22ce22401a49e7c2e05 100644 --- a/core/modules/system/theme.api.php +++ b/core/modules/system/theme.api.php @@ -448,7 +448,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/src/TermForm.php b/core/modules/taxonomy/src/TermForm.php index 65f1cfd9f169f77afa617c54c82179b3f64e9b65..2136b0f750c6959544680b9171192b714a70c9dd 100644 --- a/core/modules/taxonomy/src/TermForm.php +++ b/core/modules/taxonomy/src/TermForm.php @@ -33,7 +33,7 @@ public function form(array $form, FormStateInterface $form_state) { '#type' => 'language_select', '#title' => $this->t('Language'), '#languages' => LanguageInterface::STATE_ALL, - '#default_value' => $term->getUntranslated()->language()->id, + '#default_value' => $term->getUntranslated()->language()->getId(), '#access' => !empty($language_configuration['language_show']), ); diff --git a/core/modules/taxonomy/src/Tests/TermLanguageTest.php b/core/modules/taxonomy/src/Tests/TermLanguageTest.php index 4264c0b0138a07e372158e426ba8c8e5c30dcbd9..71caceec557d1fe7ed83645dbb9cd487aa36ecdf 100644 --- a/core/modules/taxonomy/src/Tests/TermLanguageTest.php +++ b/core/modules/taxonomy/src/Tests/TermLanguageTest.php @@ -57,7 +57,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'); diff --git a/core/modules/taxonomy/src/Tests/TokenReplaceTest.php b/core/modules/taxonomy/src/Tests/TokenReplaceTest.php index d343995ced64979124e2ee1ecf47a4ac2724632d..f25591ba825a3567d88d21e58d5de7f8c80d53be 100644 --- a/core/modules/taxonomy/src/Tests/TokenReplaceTest.php +++ b/core/modules/taxonomy/src/Tests/TokenReplaceTest.php @@ -91,7 +91,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))); } @@ -111,7 +111,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))); } @@ -122,7 +122,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))); } @@ -138,7 +138,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))); } @@ -147,7 +147,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/taxonomy.module b/core/modules/taxonomy/taxonomy.module index e4ecc3bc0560c0a909b1a5dd3c3b6fa16ebbb576..fc423d6a18c84612c4a76e3682a175b7f2c99815 100644 --- a/core/modules/taxonomy/taxonomy.module +++ b/core/modules/taxonomy/taxonomy.module @@ -683,7 +683,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/toolbar/toolbar.module b/core/modules/toolbar/toolbar.module index fe49c20f0be8339a32fd64efb817f94ddd071d1c..a52658929f1ed7c058663212b8a8c9db32ebe466 100644 --- a/core/modules/toolbar/toolbar.module +++ b/core/modules/toolbar/toolbar.module @@ -148,7 +148,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(); $subtrees_attached['js'][] = array( 'type' => 'setting', 'data' => array('toolbar' => array( diff --git a/core/modules/update/update.fetch.inc b/core/modules/update/update.fetch.inc index 64f3ebd174a1e2981079362db84280a644e4e245..fae02d4cf97d09801251940d95e5be6cdb32ef79 100644 --- a/core/modules/update/update.fetch.inc +++ b/core/modules/update/update.fetch.inc @@ -74,7 +74,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/src/AccountForm.php b/core/modules/user/src/AccountForm.php index 99ef5f2f7fffe0cdfcb729fc089dfc0244b49304..a8f39aa5b34f884c5163b525848b771df37f874a 100644 --- a/core/modules/user/src/AccountForm.php +++ b/core/modules/user/src/AccountForm.php @@ -240,9 +240,9 @@ public function form(array $form, FormStateInterface $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(FALSE); + $user_preferred_admin_langcode = $register ? $language_interface->getId() : $account->getPreferredAdminLangcode(FALSE); // Is the user preferred language added? $user_language_added = FALSE; diff --git a/core/modules/user/src/Entity/User.php b/core/modules/user/src/Entity/User.php index 6bb533c344e2d0922be4ab5f4de8b8835bf54eb5..f659d1446ea323ebcc7db7a702644aa0d2585452 100644 --- a/core/modules/user/src/Entity/User.php +++ b/core/modules/user/src/Entity/User.php @@ -372,10 +372,10 @@ function getPreferredLangcode($fallback_to_default = TRUE) { $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 $fallback_to_default ? language_default()->id : ''; + return $fallback_to_default ? language_default()->getId() : ''; } } @@ -386,10 +386,10 @@ function getPreferredAdminLangcode($fallback_to_default = TRUE) { $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 $fallback_to_default ? language_default()->id : ''; + return $fallback_to_default ? language_default()->getId() : ''; } } diff --git a/core/modules/user/src/Form/UserPasswordForm.php b/core/modules/user/src/Form/UserPasswordForm.php index 378f8f3a1854b4067d1b50857cb0df585c1a1ef1..f06ba2923ff5c9333ec0559b030a92ef454b4b8b 100644 --- a/core/modules/user/src/Form/UserPasswordForm.php +++ b/core/modules/user/src/Form/UserPasswordForm.php @@ -129,7 +129,7 @@ public function validateForm(array &$form, FormStateInterface $form_state) { * {@inheritdoc} */ public function submitForm(array &$form, FormStateInterface $form_state) { - $langcode = $this->languageManager->getCurrentLanguage()->id; + $langcode = $this->languageManager->getCurrentLanguage()->getId(); $account = $form_state->getValue('account'); // Mail one time login URL and instructions using current language. diff --git a/core/modules/user/src/Plugin/LanguageNegotiation/LanguageNegotiationUser.php b/core/modules/user/src/Plugin/LanguageNegotiation/LanguageNegotiationUser.php index f2c99fe5d2e81710f619ebcf27ffde7772136625..623dac6dc3cfdb5ab9415bb83b60af6cc1d09fbe 100644 --- a/core/modules/user/src/Plugin/LanguageNegotiation/LanguageNegotiationUser.php +++ b/core/modules/user/src/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/src/Tests/UserInstallTest.php b/core/modules/user/src/Tests/UserInstallTest.php index 6b5ddd437ad67eaf8d7e8a7f09f70f7f9985361a..33a3238fe0747d0fd3d12efa28b55915887202ae 100644 --- a/core/modules/user/src/Tests/UserInstallTest.php +++ b/core/modules/user/src/Tests/UserInstallTest.php @@ -47,8 +47,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/src/Tests/UserLanguageCreationTest.php b/core/modules/user/src/Tests/UserLanguageCreationTest.php index 65e37f913b4b81778f5689aa063c010e8c786a4b..fc95906f3b83c78955ff71e8a115b8fb4409128c 100644 --- a/core/modules/user/src/Tests/UserLanguageCreationTest.php +++ b/core/modules/user/src/Tests/UserLanguageCreationTest.php @@ -63,7 +63,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(); @@ -81,7 +81,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/src/Tests/UserRegistrationTest.php b/core/modules/user/src/Tests/UserRegistrationTest.php index f6a34bd43aceeb15fb7a3f17ceb40cd051474caa..a1f189da9f1d2b00b0255900dc5d68e749a4abd6 100644 --- a/core/modules/user/src/Tests/UserRegistrationTest.php +++ b/core/modules/user/src/Tests/UserRegistrationTest.php @@ -182,8 +182,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/src/Tests/UserRoleAdminTest.php b/core/modules/user/src/Tests/UserRoleAdminTest.php index 7d18b0a2ed7cf4a998aaa027083b18280690aba4..427ad8f94aa039a19596cfa4d05bd29fc29f21bc 100644 --- a/core/modules/user/src/Tests/UserRoleAdminTest.php +++ b/core/modules/user/src/Tests/UserRoleAdminTest.php @@ -27,7 +27,7 @@ protected 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/src/Tests/UserTokenReplaceTest.php b/core/modules/user/src/Tests/UserTokenReplaceTest.php index 3d9e8fe5a5c6ee3824abccb74415f78faa175a56..897e2aaf495c696547e37d85621cc3253b71bf24 100644 --- a/core/modules/user/src/Tests/UserTokenReplaceTest.php +++ b/core/modules/user/src/Tests/UserTokenReplaceTest.php @@ -59,17 +59,17 @@ function testUserTokenReplacement() { $tests['[user:mail]'] = String::checkPlain($account->getEmail()); $tests['[user:url]'] = $account->url('canonical', $url_options); $tests['[user:edit-url]'] = $account->url('edit-form', $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]'] = String::checkPlain(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))); } @@ -79,7 +79,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))); } @@ -91,7 +91,7 @@ function testUserTokenReplacement() { // Generate tokens with interface language. $link = \Drupal::url('user.page', [], 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 eca1692cbec69fa13c3c3b291398b8cfc7e6eb19..134c251b93c95ee2a301e1c5feb218eb70e55d7c 100644 --- a/core/modules/user/user.install +++ b/core/modules/user/user.install @@ -67,7 +67,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 61de86c6c985be8bde647828a887a63d62a3beaf..9146aac13fb512cfc640a2934d8067811b814721 100644 --- a/core/modules/user/user.module +++ b/core/modules/user/user.module @@ -1322,7 +1322,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/src/Entity/Render/DefaultLanguageRenderer.php b/core/modules/views/src/Entity/Render/DefaultLanguageRenderer.php index 18875f5665f5be12b052bdd8fd93523fcad5412e..2e99c12714212b846bbb48189f7dcd22b66b9e13 100644 --- a/core/modules/views/src/Entity/Render/DefaultLanguageRenderer.php +++ b/core/modules/views/src/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/src/Plugin/views/PluginBase.php b/core/modules/views/src/Plugin/views/PluginBase.php index 179fc0573b49e8d9701060165354713185b87f1e..2edf4c321b83495077e59f9be7bd506a59883395 100644 --- a/core/modules/views/src/Plugin/views/PluginBase.php +++ b/core/modules/views/src/Plugin/views/PluginBase.php @@ -459,14 +459,14 @@ public static function queryLanguageSubstitutions() { $manager = \Drupal::languageManager(); // Handle default language. - $default = $manager->getDefaultLanguage()->id; + $default = $manager->getDefaultLanguage()->getId(); $changes[PluginBase::VIEWS_QUERY_LANGUAGE_SITE_DEFAULT] = $default; // Handle negotiated languages. $types = $manager->getDefinedLanguageTypesInfo(); foreach ($types as $id => $type) { if (isset($type['name'])) { - $changes['***LANGUAGE_' . $id . '***'] = $manager->getCurrentLanguage($id)->id; + $changes['***LANGUAGE_' . $id . '***'] = $manager->getCurrentLanguage($id)->getId(); } } diff --git a/core/modules/views/src/Plugin/views/cache/CachePluginBase.php b/core/modules/views/src/Plugin/views/cache/CachePluginBase.php index 57873e45a2582a4bf04b4f9dca14f2101002ac72..d8cdd7fd5a1126729b246ef9c1835fab32d1e96d 100644 --- a/core/modules/views/src/Plugin/views/cache/CachePluginBase.php +++ b/core/modules/views/src/Plugin/views/cache/CachePluginBase.php @@ -306,7 +306,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'], ); foreach (array('exposed_info', 'page', 'sort', 'order', 'items_per_page', 'offset') as $key) { @@ -335,7 +335,7 @@ public function generateOutputKey() { 'roles' => $user->getRoles(), 'super-user' => $user->id() == 1, // special caching for super user. 'theme' => \Drupal::theme()->getActiveTheme()->getName(), - 'langcode' => \Drupal::languageManager()->getCurrentLanguage()->id, + 'langcode' => \Drupal::languageManager()->getCurrentLanguage()->getId(), 'base_url' => $GLOBALS['base_url'], ); diff --git a/core/modules/views/src/Plugin/views/display/DisplayPluginBase.php b/core/modules/views/src/Plugin/views/display/DisplayPluginBase.php index 7503bb70731e4447075b3362df2b80f58c46fb5a..3810df3ba7e1227b436f65f670c6b4275506c6bd 100644 --- a/core/modules/views/src/Plugin/views/display/DisplayPluginBase.php +++ b/core/modules/views/src/Plugin/views/display/DisplayPluginBase.php @@ -180,7 +180,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)) { diff --git a/core/modules/views/src/Plugin/views/wizard/WizardPluginBase.php b/core/modules/views/src/Plugin/views/wizard/WizardPluginBase.php index c8a127b7aae45b048cbf4c2acfea044b945f61f0..b6fa496d8310d240fb21d78797f31b3e0db8f5bd 100644 --- a/core/modules/views/src/Plugin/views/wizard/WizardPluginBase.php +++ b/core/modules/views/src/Plugin/views/wizard/WizardPluginBase.php @@ -693,7 +693,7 @@ protected function instantiateView($form, FormStateInterface $form_state) { 'label' => $form_state->getValue('label'), 'description' => $form_state->getValue('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/src/Tests/Entity/RowEntityRenderersTest.php b/core/modules/views/src/Tests/Entity/RowEntityRenderersTest.php index f53b53ead23f89fedc0b54542765dc74a52fc29b..e8205326fda007ed34f44cd1d0475c60e99f67b2 100644 --- a/core/modules/views/src/Tests/Entity/RowEntityRenderersTest.php +++ b/core/modules/views/src/Tests/Entity/RowEntityRenderersTest.php @@ -55,7 +55,7 @@ protected function setUp() { // The entity.node.canonical 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/src/ViewsData.php b/core/modules/views/src/ViewsData.php index cfbf254be0678a9c71c2be872c1e90796266bae1..957899405326fc5afc6b1a576fcf71d0b9ac5612 100644 --- a/core/modules/views/src/ViewsData.php +++ b/core/modules/views/src/ViewsData.php @@ -108,7 +108,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 14b3f1bde18de1a30ac4042e7d35a25193a0cd8a..d5f05294471a00f3e17eed696a983cef1899484b 100644 --- a/core/modules/views/views.api.php +++ b/core/modules/views/views.api.php @@ -579,8 +579,8 @@ function hook_views_query_substitutions(ViewExecutable $view) { return array( '***CURRENT_VERSION***' => \Drupal::VERSION, '***CURRENT_TIME***' => REQUEST_TIME, - '***LANGUAGE_language_content***' => \Drupal::languageManager()->getCurrentLanguage(LanguageInterface::TYPE_CONTENT)->id, - PluginBase::VIEWS_QUERY_LANGUAGE_SITE_DEFAULT => \Drupal::languageManager()->getDefaultLanguage()->id, + '***LANGUAGE_language_content***' => \Drupal::languageManager()->getCurrentLanguage(LanguageInterface::TYPE_CONTENT)->getId(), + PluginBase::VIEWS_QUERY_LANGUAGE_SITE_DEFAULT => \Drupal::languageManager()->getDefaultLanguage()->getId(), ); } diff --git a/core/modules/views/views.theme.inc b/core/modules/views/views.theme.inc index 06ccdcaae97ec1ef1d4e3302db1fb02f6b8856ad..ebef6f8239bb35a402f76b546a177f3b8f7f58c3 100644 --- a/core/modules/views/views.theme.inc +++ b/core/modules/views/views.theme.inc @@ -901,7 +901,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/scripts/run-tests.sh b/core/scripts/run-tests.sh old mode 100755 new mode 100644 diff --git a/core/tests/Drupal/Tests/Core/Entity/ContentEntityBaseUnitTest.php b/core/tests/Drupal/Tests/Core/Entity/ContentEntityBaseUnitTest.php index 1287b473fb53ce53f75392da95dcc84f2de0ad25..b83c2f34b641f38ab9df9dff6cf7f744d5748330 100644 --- a/core/tests/Drupal/Tests/Core/Entity/ContentEntityBaseUnitTest.php +++ b/core/tests/Drupal/Tests/Core/Entity/ContentEntityBaseUnitTest.php @@ -277,11 +277,11 @@ public function testIsTranslatable() { $this->languageManager->expects($this->any()) ->method('isMultilingual') ->will($this->returnValue(TRUE)); - $this->assertTrue($this->entity->language()->id == 'en'); + $this->assertTrue($this->entity->language()->getId() == 'en'); $this->assertFalse($this->entity->language()->isLocked()); $this->assertTrue($this->entity->isTranslatable()); - $this->assertTrue($this->entityUnd->language()->id == LanguageInterface::LANGCODE_NOT_SPECIFIED); + $this->assertTrue($this->entityUnd->language()->getId() == LanguageInterface::LANGCODE_NOT_SPECIFIED); $this->assertTrue($this->entityUnd->language()->isLocked()); $this->assertFalse($this->entityUnd->isTranslatable()); } diff --git a/core/tests/Drupal/Tests/Core/Entity/EntityManagerTest.php b/core/tests/Drupal/Tests/Core/Entity/EntityManagerTest.php index 99c783d822e272e069cfddd6385e0bea9273f2a5..b933132641973491c66f328b5d1a5c479ea30bc6 100644 --- a/core/tests/Drupal/Tests/Core/Entity/EntityManagerTest.php +++ b/core/tests/Drupal/Tests/Core/Entity/EntityManagerTest.php @@ -114,11 +114,15 @@ 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->getMock('Drupal\Core\Language\LanguageManagerInterface'); $this->languageManager->expects($this->any()) ->method('getCurrentLanguage') - ->will($this->returnValue((object) array('id' => 'en'))); + ->will($this->returnValue($language)); $this->languageManager->expects($this->any()) ->method('getLanguages') ->will($this->returnValue(array('en' => (object) array('id' => 'en')))); @@ -946,9 +950,13 @@ 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( @@ -992,8 +1000,7 @@ function testgetExtraFields() { ); $cache_id = 'entity_bundle_extra_fields:' . $entity_type_id . ':' . $bundle . ':' . $language_code; - $language = new Language(); - $language->id = $language_code; + $language = new Language(array('id' => $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 a2034e78cfa2a42b111213ad79f8d56ae960088a..653573278979f652c5f4abce5e3f2aca34b99c7b 100644 --- a/core/tests/Drupal/Tests/Core/Entity/EntityUnitTest.php +++ b/core/tests/Drupal/Tests/Core/Entity/EntityUnitTest.php @@ -233,7 +233,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/PathProcessor/PathProcessorTest.php b/core/tests/Drupal/Tests/Core/PathProcessor/PathProcessorTest.php index 320f13d765312d3fcb1e9c355c96f41077241b01..054df811c90f6fc354eabfe07beb100ac2a7b5c9 100644 --- a/core/tests/Drupal/Tests/Core/PathProcessor/PathProcessorTest.php +++ b/core/tests/Drupal/Tests/Core/PathProcessor/PathProcessorTest.php @@ -7,6 +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; @@ -44,10 +45,8 @@ protected 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; + foreach (array('en', 'fr') as $langcode) { + $language = new Language(array('id' => $langcode)); $languages[$langcode] = $language; } $this->languages = $languages; diff --git a/core/tests/Drupal/Tests/Core/Utility/TokenTest.php b/core/tests/Drupal/Tests/Core/Utility/TokenTest.php index 3736f0b9a09b55f9ed4da3b9d74b6a892acddf74..03878cb2955925a0b9cb929cc622d87a01da435d 100644 --- a/core/tests/Drupal/Tests/Core/Utility/TokenTest.php +++ b/core/tests/Drupal/Tests/Core/Utility/TokenTest.php @@ -70,8 +70,10 @@ public function testGetInfo() { ), ); - $language = $this->getMock('\Drupal\Core\Language\Language'); - $language->id = $this->randomMachineName(); + $values = array('id' => $this->randomMachineName()); + $language = $this->getMockBuilder('\Drupal\Core\Language\Language') + ->setConstructorArgs(array($values)) + ->getMock(); $this->languageManager->expects($this->once()) ->method('getCurrentLanguage') @@ -84,7 +86,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')