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

Breadcrumb

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

function ContentEntityBase::getLanguages

3 calls to ContentEntityBase::getLanguages()
ContentEntityBase::addTranslation in core/lib/Drupal/Core/Entity/ContentEntityBase.php
ContentEntityBase::getTranslationLanguages in core/lib/Drupal/Core/Entity/ContentEntityBase.php
ContentEntityBase::language in core/lib/Drupal/Core/Entity/ContentEntityBase.php
Gets the language of the entity.

File

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

Class

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

Namespace

Drupal\Core\Entity

Code

protected function getLanguages() {
    if (empty($this->languages)) {
        $this->languages = $this->languageManager()
            ->getLanguages(LanguageInterface::STATE_ALL);
        // If the entity references a language that is not or no longer available,
        // we return a mock language object to avoid disrupting the consuming
        // code.
        if (!isset($this->languages[$this->defaultLangcode])) {
            $this->languages[$this->defaultLangcode] = new Language([
                'id' => $this->defaultLangcode,
            ]);
        }
    }
    return $this->languages;
}

API Navigation

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