public function EntityBase::language in Drupal 10
Same name and namespace in other branches
- 8 core/lib/Drupal/Core/Entity/EntityBase.php \Drupal\Core\Entity\EntityBase::language()
- 9 core/lib/Drupal/Core/Entity/EntityBase.php \Drupal\Core\Entity\EntityBase::language()
1 method overrides EntityBase::language()
- ContentEntityBase::language in core/
lib/ Drupal/ Core/ Entity/ ContentEntityBase.php - Gets the language of the entity.
File
- core/
lib/ Drupal/ Core/ Entity/ EntityBase.php, line 320
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;
}