Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. ContentEntityBase.php

function ContentEntityBase::language

Overrides EntityBase::language

File

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

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

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal