W3cubDocs

/Drupal 8

protected function ContentEntityBase::getLanguages

protected ContentEntityBase::getLanguages()

File

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

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(array('id' => $this->defaultLangcode));
    }
  }
  return $this->languages;
}

© 2001–2016 by the original authors
Licensed under the GNU General Public License, version 2 and later.
Drupal is a registered trademark of Dries Buytaert.
https://api.drupal.org/api/drupal/core!lib!Drupal!Core!Entity!ContentEntityBase.php/function/ContentEntityBase::getLanguages/8.1.x