function EntityBase::language
Same name in other branches
- 9 core/lib/Drupal/Core/Entity/EntityBase.php \Drupal\Core\Entity\EntityBase::language()
- 8.9.x core/lib/Drupal/Core/Entity/EntityBase.php \Drupal\Core\Entity\EntityBase::language()
- 11.x core/lib/Drupal/Core/Entity/EntityBase.php \Drupal\Core\Entity\EntityBase::language()
Overrides EntityInterface::language
1 call to EntityBase::language()
- EntityBase::toUrl in core/
lib/ Drupal/ Core/ Entity/ EntityBase.php
1 method overrides EntityBase::language()
- ContentEntityBase::language in core/
lib/ Drupal/ Core/ Entity/ ContentEntityBase.php
File
-
core/
lib/ Drupal/ Core/ Entity/ EntityBase.php, line 335
Class
- EntityBase
- Defines a base entity class.
Namespace
Drupal\Core\EntityCode
public function language() {
if ($key = $this->getEntityType()
->getKey('langcode')) {
$langcode = $this->{$key};
$language = $this->languageManager()
->getLanguage($langcode);
if ($language) {
return $language;
}
}
// Make sure we return a proper language object.
$langcode = !empty($this->langcode) ? $this->langcode : LanguageInterface::LANGCODE_NOT_SPECIFIED;
$language = new Language([
'id' => $langcode,
]);
return $language;
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.