ContentEntityBase::language

public ContentEntityBase::language()

Gets the language of the entity.

Return value

\Drupal\Core\Language\LanguageInterface The language object.

Overrides Entity::language

File

core/lib/Drupal/Core/Entity/ContentEntityBase.php, line 599

Class

ContentEntityBase
Implements Entity Field API specific enhancements to the Entity class.

Namespace

Drupal\Core\Entity

Code

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
public function language() {
  $language = NULL;
  if ($this->activeLangcode != LanguageInterface::LANGCODE_DEFAULT) {
    if (!isset($this->languages[$this->activeLangcode])) {
      $this->getLanguages();
    }
    $language = $this->languages[$this->activeLangcode];
  }
  else {
    // @todo Avoid this check by getting the language from the language
    //   manager directly in https://www.drupal.org/node/2303877.
    if (!isset($this->languages[$this->defaultLangcode])) {
      $this->getLanguages();
    }
    $language = $this->languages[$this->defaultLangcode];
  }
  return $language;
}
doc_Drupal
2025-01-10 15:47:30
Comments
Leave a Comment

Please login to continue.