Commit 66762a53 authored by catch's avatar catch

Issue #2340667 by YesCT, Pedro Lozano, alexpott, martin107: Protect...

Issue #2340667 by YesCT, Pedro Lozano, alexpott, martin107: Protect Drupal\Core\Language\Language::id, and use getId().
parent 51c10124
...@@ -752,7 +752,7 @@ function _l($text, $path, array $options = array()) { ...@@ -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 // Add a hreflang attribute if we know the language of this link's url and
// hreflang has not already been set. // hreflang has not already been set.
if (!empty($variables['options']['language']) && !isset($variables['options']['attributes']['hreflang'])) { 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. // 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) { ...@@ -1525,7 +1525,7 @@ function _drupal_add_js($data = NULL, $options = NULL) {
'currentPath' => $current_path, 'currentPath' => $current_path,
'currentPathIsAdmin' => $current_path_is_admin, 'currentPathIsAdmin' => $current_path_is_admin,
'isFront' => drupal_is_front_page(), '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)) { if (!empty($current_query)) {
ksort($current_query); ksort($current_query);
......
...@@ -1006,7 +1006,7 @@ function template_preprocess_links(&$variables) { ...@@ -1006,7 +1006,7 @@ function template_preprocess_links(&$variables) {
$link_element['#options']['set_active_class'] = TRUE; $link_element['#options']['set_active_class'] = TRUE;
if (!empty($link['language'])) { 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 // Add a "data-drupal-link-query" attribute to let the
......
...@@ -719,7 +719,7 @@ function update_language_list($flags = LanguageInterface::STATE_CONFIGURABLE) { ...@@ -719,7 +719,7 @@ function update_language_list($flags = LanguageInterface::STATE_CONFIGURABLE) {
$langcode = substr($langcode_config_name, strlen('language.entity.')); $langcode = substr($langcode_config_name, strlen('language.entity.'));
$info = \Drupal::config($langcode_config_name)->get(); $info = \Drupal::config($langcode_config_name)->get();
$languages[$langcode] = new Language(array( $languages[$langcode] = new Language(array(
'default' => ($info['id'] == $default->id), 'default' => ($info['id'] == $default->getId()),
'name' => $info['label'], 'name' => $info['label'],
'id' => $info['id'], 'id' => $info['id'],
'direction' => $info['direction'], 'direction' => $info['direction'],
...@@ -731,7 +731,7 @@ function update_language_list($flags = LanguageInterface::STATE_CONFIGURABLE) { ...@@ -731,7 +731,7 @@ function update_language_list($flags = LanguageInterface::STATE_CONFIGURABLE) {
} }
else { else {
// No language module, so use the default language only. // 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. // Add the special languages, they will be filtered later if needed.
$languages += \Drupal::languageManager()->getDefaultLockedLanguages($default->getWeight()); $languages += \Drupal::languageManager()->getDefaultLockedLanguages($default->getWeight());
} }
......
...@@ -45,7 +45,7 @@ public function getContext() { ...@@ -45,7 +45,7 @@ public function getContext() {
$context_parts = array(); $context_parts = array();
if ($this->languageManager->isMultilingual()) { if ($this->languageManager->isMultilingual()) {
foreach ($this->languageManager->getLanguageTypes() as $type) { foreach ($this->languageManager->getLanguageTypes() as $type) {
$context_parts[] = $this->languageManager->getCurrentLanguage($type)->id; $context_parts[] = $this->languageManager->getCurrentLanguage($type)->getId();
} }
} }
return implode(':', $context_parts); return implode(':', $context_parts);
......
...@@ -189,7 +189,7 @@ protected function doLoadMultiple(array $ids = NULL) { ...@@ -189,7 +189,7 @@ protected function doLoadMultiple(array $ids = NULL) {
*/ */
protected function doCreate(array $values) { protected function doCreate(array $values) {
// Set default language to site default if not provided. // 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); $entity = new $this->entityClass($values, $this->entityTypeId);
return $entity; return $entity;
......
...@@ -133,7 +133,7 @@ public function format($timestamp, $type = 'medium', $format = '', $timezone = N ...@@ -133,7 +133,7 @@ public function format($timestamp, $type = 'medium', $format = '', $timezone = N
} }
if (empty($langcode)) { if (empty($langcode)) {
$langcode = $this->languageManager->getCurrentLanguage()->id; $langcode = $this->languageManager->getCurrentLanguage()->getId();
} }
// Create a DrupalDateTime object from the timestamp and timezone. // Create a DrupalDateTime object from the timestamp and timezone.
......
...@@ -43,7 +43,7 @@ class DrupalDateTime extends DateTimePlus { ...@@ -43,7 +43,7 @@ class DrupalDateTime extends DateTimePlus {
*/ */
public function __construct($time = 'now', $timezone = NULL, $settings = array()) { public function __construct($time = 'now', $timezone = NULL, $settings = array()) {
if (!isset($settings['langcode'])) { if (!isset($settings['langcode'])) {
$settings['langcode'] = \Drupal::languageManager()->getCurrentLanguage()->id; $settings['langcode'] = \Drupal::languageManager()->getCurrentLanguage()->getId();
} }
// Instantiate the parent class. // Instantiate the parent class.
......
...@@ -475,7 +475,7 @@ public function language() { ...@@ -475,7 +475,7 @@ public function language() {
protected function setDefaultLangcode() { protected function setDefaultLangcode() {
// Get the language code if the property exists. // Get the language code if the property exists.
if ($this->hasField('langcode') && ($item = $this->get('langcode')) && isset($item->language)) { 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)) { if (empty($this->defaultLangcode)) {
......
...@@ -91,7 +91,7 @@ public function getFormLangcode(FormStateInterface $form_state) { ...@@ -91,7 +91,7 @@ public function getFormLangcode(FormStateInterface $form_state) {
// Imply a 'view' operation to ensure users edit entities in the same // Imply a 'view' operation to ensure users edit entities in the same
// language they are displayed. This allows to keep contextual editing // language they are displayed. This allows to keep contextual editing
// working also for multilingual entities. // 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'); return $form_state->get('langcode');
} }
...@@ -100,7 +100,7 @@ public function getFormLangcode(FormStateInterface $form_state) { ...@@ -100,7 +100,7 @@ public function getFormLangcode(FormStateInterface $form_state) {
* {@inheritdoc} * {@inheritdoc}
*/ */
public function isDefaultFormLangcode(FormStateInterface $form_state) { 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();
} }
/** /**
......
...@@ -335,7 +335,7 @@ public function getBaseFieldDefinitions($entity_type_id) { ...@@ -335,7 +335,7 @@ public function getBaseFieldDefinitions($entity_type_id) {
// Check the static cache. // Check the static cache.
if (!isset($this->baseFieldDefinitions[$entity_type_id])) { if (!isset($this->baseFieldDefinitions[$entity_type_id])) {
// Not prepared, try to load from cache. // 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)) { if ($cache = $this->cacheBackend->get($cid)) {
$this->baseFieldDefinitions[$entity_type_id] = $cache->data; $this->baseFieldDefinitions[$entity_type_id] = $cache->data;
} }
...@@ -433,7 +433,7 @@ public function getFieldDefinitions($entity_type_id, $bundle) { ...@@ -433,7 +433,7 @@ public function getFieldDefinitions($entity_type_id, $bundle) {
if (!isset($this->fieldDefinitions[$entity_type_id][$bundle])) { if (!isset($this->fieldDefinitions[$entity_type_id][$bundle])) {
$base_field_definitions = $this->getBaseFieldDefinitions($entity_type_id); $base_field_definitions = $this->getBaseFieldDefinitions($entity_type_id);
// Not prepared, try to load from cache. // 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)) { if ($cache = $this->cacheBackend->get($cid)) {
$bundle_field_definitions = $cache->data; $bundle_field_definitions = $cache->data;
} }
...@@ -541,7 +541,7 @@ public function getFieldStorageDefinitions($entity_type_id) { ...@@ -541,7 +541,7 @@ public function getFieldStorageDefinitions($entity_type_id) {
} }
} }
// Not prepared, try to load from cache. // 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)) { if ($cache = $this->cacheBackend->get($cid)) {
$field_storage_definitions = $cache->data; $field_storage_definitions = $cache->data;
} }
...@@ -680,7 +680,7 @@ public function getBundleInfo($entity_type) { ...@@ -680,7 +680,7 @@ public function getBundleInfo($entity_type) {
*/ */
public function getAllBundleInfo() { public function getAllBundleInfo() {
if (empty($this->bundleInfo)) { if (empty($this->bundleInfo)) {
$langcode = $this->languageManager->getCurrentLanguage()->id; $langcode = $this->languageManager->getCurrentLanguage()->getId();
if ($cache = $this->cacheBackend->get("entity_bundle_info:$langcode")) { if ($cache = $this->cacheBackend->get("entity_bundle_info:$langcode")) {
$this->bundleInfo = $cache->data; $this->bundleInfo = $cache->data;
} }
...@@ -721,7 +721,7 @@ public function getExtraFields($entity_type_id, $bundle) { ...@@ -721,7 +721,7 @@ public function getExtraFields($entity_type_id, $bundle) {
// Read from the persistent cache. Since hook_entity_extra_field_info() and // Read from the persistent cache. Since hook_entity_extra_field_info() and
// hook_entity_extra_field_info_alter() might contain t() calls, we cache // hook_entity_extra_field_info_alter() might contain t() calls, we cache
// per language. // 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); $cached = $this->cacheBackend->get($cache_id);
if ($cached) { if ($cached) {
$this->extraFields[$entity_type_id][$bundle] = $cached->data; $this->extraFields[$entity_type_id][$bundle] = $cached->data;
...@@ -783,7 +783,7 @@ public function getTranslationFromContext(EntityInterface $entity, $langcode = N ...@@ -783,7 +783,7 @@ public function getTranslationFromContext(EntityInterface $entity, $langcode = N
if ($entity instanceof TranslatableInterface) { if ($entity instanceof TranslatableInterface) {
if (empty($langcode)) { 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 // Retrieve language fallback candidates to perform the entity language
...@@ -794,7 +794,7 @@ public function getTranslationFromContext(EntityInterface $entity, $langcode = N ...@@ -794,7 +794,7 @@ public function getTranslationFromContext(EntityInterface $entity, $langcode = N
// Ensure the default language has the proper language code. // Ensure the default language has the proper language code.
$default_language = $entity->getUntranslated()->language(); $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. // Return the most fitting entity translation.
foreach ($candidates as $candidate) { foreach ($candidates as $candidate) {
...@@ -849,7 +849,7 @@ protected function getAllDisplayModesByEntityType($display_type) { ...@@ -849,7 +849,7 @@ protected function getAllDisplayModesByEntityType($display_type) {
if (!isset($this->displayModeInfo[$display_type])) { if (!isset($this->displayModeInfo[$display_type])) {
$key = 'entity_' . $display_type . '_info'; $key = 'entity_' . $display_type . '_info';
$entity_type_id = 'entity_' . $display_type; $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")) { if ($cache = $this->cacheBackend->get("$key:$langcode")) {
$this->displayModeInfo[$display_type] = $cache->data; $this->displayModeInfo[$display_type] = $cache->data;
} }
......
...@@ -109,7 +109,7 @@ public function view(EntityInterface $entity, $view_mode = 'full', $langcode = N ...@@ -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) { public function viewMultiple(array $entities = array(), $view_mode = 'full', $langcode = NULL) {
if (!isset($langcode)) { if (!isset($langcode)) {
$langcode = $this->languageManager->getCurrentLanguage(LanguageInterface::TYPE_CONTENT)->id; $langcode = $this->languageManager->getCurrentLanguage(LanguageInterface::TYPE_CONTENT)->getId();
} }
$build_list = array( $build_list = array(
......
...@@ -94,7 +94,7 @@ public static function createInstance(ContainerInterface $container, EntityTypeI ...@@ -94,7 +94,7 @@ public static function createInstance(ContainerInterface $container, EntityTypeI
*/ */
public function doCreate(array $values = array()) { public function doCreate(array $values = array()) {
// Set default language to site default if not provided. // 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); $entity = new $this->entityClass($values, $this->entityTypeId);
// @todo This is handled by ContentEntityStorageBase, which assumes // @todo This is handled by ContentEntityStorageBase, which assumes
......
...@@ -1112,8 +1112,8 @@ protected function mapToDataStorageRecord(EntityInterface $entity, $table_name = ...@@ -1112,8 +1112,8 @@ protected function mapToDataStorageRecord(EntityInterface $entity, $table_name =
$table_name = $this->dataTable; $table_name = $this->dataTable;
} }
$record = $this->mapToStorageRecord($entity, $table_name); $record = $this->mapToStorageRecord($entity, $table_name);
$record->langcode = $entity->language()->id; $record->langcode = $entity->language()->getId();
$record->default_langcode = intval($record->langcode == $entity->getUntranslated()->language()->id); $record->default_langcode = intval($record->langcode == $entity->getUntranslated()->language()->getId());
return $record; return $record;
} }
...@@ -1199,7 +1199,7 @@ protected function loadFieldItems(array $entities) { ...@@ -1199,7 +1199,7 @@ protected function loadFieldItems(array $entities) {
foreach ($entities as $key => $entity) { foreach ($entities as $key => $entity) {
$bundles[$entity->bundle()] = TRUE; $bundles[$entity->bundle()] = TRUE;
$ids[] = $load_current ? $key : $entity->getRevisionId(); $ids[] = $load_current ? $key : $entity->getRevisionId();
$default_langcodes[$key] = $entity->getUntranslated()->language()->id; $default_langcodes[$key] = $entity->getUntranslated()->language()->getId();
} }
// Collect impacted fields. // Collect impacted fields.
...@@ -1275,7 +1275,7 @@ protected function saveFieldItems(EntityInterface $entity, $update = TRUE) { ...@@ -1275,7 +1275,7 @@ protected function saveFieldItems(EntityInterface $entity, $update = TRUE) {
$id = $entity->id(); $id = $entity->id();
$bundle = $entity->bundle(); $bundle = $entity->bundle();
$entity_type = $entity->getEntityTypeId(); $entity_type = $entity->getEntityTypeId();
$default_langcode = $entity->getUntranslated()->language()->id; $default_langcode = $entity->getUntranslated()->language()->getId();
$translation_langcodes = array_keys($entity->getTranslationLanguages()); $translation_langcodes = array_keys($entity->getTranslationLanguages());
$table_mapping = $this->getTableMapping(); $table_mapping = $this->getTableMapping();
......
...@@ -94,7 +94,7 @@ public function onRespond(FilterResponseEvent $event) { ...@@ -94,7 +94,7 @@ public function onRespond(FilterResponseEvent $event) {
$response->headers->set('X-UA-Compatible', 'IE=edge,chrome=1', FALSE); $response->headers->set('X-UA-Compatible', 'IE=edge,chrome=1', FALSE);
// Set the Content-language header. // 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 // Attach globally-declared headers to the response object so that Symfony
// can send them for us correctly. // can send them for us correctly.
......
...@@ -41,7 +41,7 @@ class Language implements LanguageInterface { ...@@ -41,7 +41,7 @@ class Language implements LanguageInterface {
* *
* @var string * @var string
*/ */
public $id = ''; protected $id = '';
/** /**
* The direction, left-to-right, or right-to-left. * The direction, left-to-right, or right-to-left.
......
...@@ -134,7 +134,7 @@ public function getLanguages($flags = LanguageInterface::STATE_CONFIGURABLE) { ...@@ -134,7 +134,7 @@ public function getLanguages($flags = LanguageInterface::STATE_CONFIGURABLE) {
if (!isset($this->languages)) { if (!isset($this->languages)) {
// No language module, so use the default language only. // No language module, so use the default language only.
$default = $this->getDefaultLanguage(); $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. // Add the special languages, they will be filtered later if needed.
$this->languages += $this->getDefaultLockedLanguages($default->getWeight()); $this->languages += $this->getDefaultLockedLanguages($default->getWeight());
} }
......
...@@ -100,7 +100,7 @@ public function preparePage(HtmlPage $page, &$page_array) { ...@@ -100,7 +100,7 @@ public function preparePage(HtmlPage $page, &$page_array) {
// HTML element attributes. // HTML element attributes.
$language_interface = $this->languageManager->getCurrentLanguage(); $language_interface = $this->languageManager->getCurrentLanguage();
$html_attributes = $page->getHtmlAttributes(); $html_attributes = $page->getHtmlAttributes();
$html_attributes['lang'] = $language_interface->id; $html_attributes['lang'] = $language_interface->getId();
$html_attributes['dir'] = $language_interface->getDirection(); $html_attributes['dir'] = $language_interface->getDirection();
$this->setDefaultMetaTags($page); $this->setDefaultMetaTags($page);
......
...@@ -157,7 +157,7 @@ public function getPathByAlias($alias, $langcode = NULL) { ...@@ -157,7 +157,7 @@ public function getPathByAlias($alias, $langcode = NULL) {
// language. If we used a language different from the one conveyed by the // 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 // requested URL, we might end up being unable to check if there is a path
// alias matching the URL 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 we already know that there are no paths for this alias simply return.
if (empty($alias) || !empty($this->noPath[$langcode][$alias])) { if (empty($alias) || !empty($this->noPath[$langcode][$alias])) {
...@@ -191,7 +191,7 @@ public function getAliasByPath($path, $langcode = NULL) { ...@@ -191,7 +191,7 @@ public function getAliasByPath($path, $langcode = NULL) {
// language. If we used a language different from the one conveyed by the // 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 // requested URL, we might end up being unable to check if there is a path
// alias matching the URL 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 / // 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, // is not in the list, then there is no need to do anything further,
......
...@@ -45,7 +45,7 @@ public function processInbound($path, Request $request) { ...@@ -45,7 +45,7 @@ public function processInbound($path, Request $request) {
*/ */
public function processOutbound($path, &$options = array(), Request $request = NULL) { public function processOutbound($path, &$options = array(), Request $request = NULL) {
if (empty($options['alias'])) { 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); $path = $this->aliasManager->getAliasByPath($path, $langcode);
} }
return $path; return $path;
......
...@@ -170,7 +170,7 @@ public static function processMachineName(&$element, FormStateInterface $form_st ...@@ -170,7 +170,7 @@ public static function processMachineName(&$element, FormStateInterface $form_st
'machineName' => array( 'machineName' => array(
'#' . $source['#id'] => $element['#machine_name'], '#' . $source['#id'] => $element['#machine_name'],
), ),
'langcode' => $language->id, 'langcode' => $language->getId(),
), ),
); );
$element['#attached']['library'][] = 'core/drupal.machine-name'; $element['#attached']['library'][] = 'core/drupal.machine-name';
......
...@@ -185,10 +185,10 @@ public function isAnonymous() { ...@@ -185,10 +185,10 @@ public function isAnonymous() {
function getPreferredLangcode($fallback_to_default = TRUE) { function getPreferredLangcode($fallback_to_default = TRUE) {
$language_list = language_list(); $language_list = language_list();
if (!empty($this->preferred_langcode) && isset($language_list[$this->preferred_langcode])) { 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 { 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) { ...@@ -198,10 +198,10 @@ function getPreferredLangcode($fallback_to_default = TRUE) {
function getPreferredAdminLangcode($fallback_to_default = TRUE) { function getPreferredAdminLangcode($fallback_to_default = TRUE) {
$language_list = language_list(); $language_list = language_list();
if (!empty($this->preferred_admin_langcode) && isset($language_list[$this->preferred_admin_langcode])) { 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 { else {
return $fallback_to_default ? language_default()->id : ''; return $fallback_to_default ? language_default()->getId() : '';
} }
} }
......
...@@ -61,7 +61,7 @@ class TranslationManager implements TranslationInterface, TranslatorInterface { ...@@ -61,7 +61,7 @@ class TranslationManager implements TranslationInterface, TranslatorInterface {
*/ */
public function __construct(LanguageManagerInterface $language_manager) { public function __construct(LanguageManagerInterface $language_manager) {
$this->languageManager = $language_manager; $this->languageManager = $language_manager;
$this->defaultLangcode = $language_manager->getDefaultLanguage()->id; $this->defaultLangcode = $language_manager->getDefaultLanguage()->getId();
} }
/** /**
......
...@@ -56,7 +56,7 @@ public function getValue() { ...@@ -56,7 +56,7 @@ public function getValue() {
public function setValue($value, $notify = TRUE) { public function setValue($value, $notify = TRUE) {
// Support passing language objects. // Support passing language objects.
if (is_object($value)) { if (is_object($value)) {
$this->id = $value->id; $this->id = $value->getId();
$this->language = $value; $this->language = $value;
} }
elseif (isset($value) && !is_scalar($value)) { elseif (isset($value) && !is_scalar($value)) {
...@@ -88,7 +88,7 @@ public function id() { ...@@ -88,7 +88,7 @@ public function id() {
return $this->id; return $this->id;
} }
elseif (isset($this->language)) { elseif (isset($this->language)) {
return $this->language->id; return $this->language->getId();
} }
} }
......
...@@ -94,7 +94,7 @@ public function generate($text, Url $url) { ...@@ -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 // Add a hreflang attribute if we know the language of this link's url and
// hreflang has not already been set. // hreflang has not already been set.
if (!empty($variables['options']['language']) && !isset($variables['options']['attributes']['hreflang'])) { 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. // Set the "active" class if the 'set_active_class' option is not empty.
......
...@@ -311,7 +311,7 @@ public function findWithPrefix(array $tokens, $prefix, $delimiter = ':') { ...@@ -311,7 +311,7 @@ public function findWithPrefix(array $tokens, $prefix, $delimiter = ':') {
*/ */
public function getInfo() { public function getInfo() {
if (is_null($this->tokenInfo)) { 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); $cache = $this->cache->get($cache_id);
if ($cache) { if ($cache) {
$this->tokenInfo = $cache->data; $this->tokenInfo = $cache->data;
......
...@@ -55,7 +55,7 @@ public function setLocale($locale) { ...@@ -55,7 +55,7 @@ public function setLocale($locale) {
* Implements \Symfony\Component\Translation\TranslatorInterface::getLocale(). * Implements \Symfony\Component\Translation\TranslatorInterface::getLocale().
*/ */
public function getLocale() { public function getLocale() {
return $this->locale ? $this->locale : \Drupal::languageManager()->getCurrentLanguage()->id; return $this->locale ? $this->locale : \Drupal::languageManager()->getCurrentLanguage()->getId();
} }
/** /**
......
...@@ -101,7 +101,7 @@ public function execute($entity = NULL) { ...@@ -101,7 +101,7 @@ public function execute($entity = NULL) {
$langcode = $recipient_account->getPreferredLangcode(); $langcode = $recipient_account->getPreferredLangcode();
} }
else { else {
$langcode = language_default()->id; $langcode = language_default()->getId();
} }
$params = array('context' => $this->configuration); $params = array('context' => $this->configuration);
......
...@@ -32,7 +32,7 @@ public function form(array $form, FormStateInterface $form_state) { ...@@ -32,7 +32,7 @@ public function form(array $form, FormStateInterface $form_state) {
$form['langcode'] = array( $form['langcode'] = array(
'#title' => $this->t('Language'), '#title' => $this->t('Language'),
'#type' => 'language_select', '#type' => 'language_select',
'#default_value' => $feed->language()->id, '#default_value' => $feed->language()->getId(),
'#languages' => LanguageInterface::STATE_ALL, '#languages' => LanguageInterface::STATE_ALL,