function ContentEntityBase::language

Same name in other branches
  1. 9 core/lib/Drupal/Core/Entity/ContentEntityBase.php \Drupal\Core\Entity\ContentEntityBase::language()
  2. 10 core/lib/Drupal/Core/Entity/ContentEntityBase.php \Drupal\Core\Entity\ContentEntityBase::language()
  3. 11.x core/lib/Drupal/Core/Entity/ContentEntityBase.php \Drupal\Core\Entity\ContentEntityBase::language()

Overrides EntityBase::language

File

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

Class

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

Namespace

Drupal\Core\Entity

Code

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;
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.