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()) {
// 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);
......
......@@ -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
......
......@@ -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());
}
......
......@@ -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);
......
......@@ -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;
......
......@@ -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.
......
......@@ -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.
......
......@@ -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)) {
......
......@@ -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();
}
/**
......
......@@ -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;
}
......
......@@ -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(
......
......@@ -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
......
......@@ -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();
......
......@@ -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.
......
......@@ -41,7 +41,7 @@ class Language implements LanguageInterface {
*
* @var string
*/
public $id = '';
protected $id = '';
/**
* The direction, left-to-right, or right-to-left.
......
......@@ -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());
}
......
......@@ -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);
......
......@@ -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,
......
......@@ -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;
......
......@@ -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';
......
......@@ -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() : '';
}
}
......
......@@ -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();
}
/**
......
......@@ -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();
}
}
......
......@@ -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.
......
......@@ -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;
......
......@@ -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();
}
/**
......
......@@ -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);
......
......@@ -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,
);
......
......@@ -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']);
......
......@@ -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());
}
}
}
......
......@@ -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',
......
......@@ -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'],
);
......
......@@ -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);
}
......
......@@ -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);
}
......
......@@ -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])) {
......
......@@ -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.
......
......@@ -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'],
);
......
......@@ -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)));
}
}
......
......@@ -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.
......
......@@ -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());
......
......@@ -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',
......