function ContentEntityBase::getTranslationLanguages

Same name in other branches
  1. 9 core/lib/Drupal/Core/Entity/ContentEntityBase.php \Drupal\Core\Entity\ContentEntityBase::getTranslationLanguages()
  2. 8.9.x core/lib/Drupal/Core/Entity/ContentEntityBase.php \Drupal\Core\Entity\ContentEntityBase::getTranslationLanguages()
  3. 11.x core/lib/Drupal/Core/Entity/ContentEntityBase.php \Drupal\Core\Entity\ContentEntityBase::getTranslationLanguages()
1 call to ContentEntityBase::getTranslationLanguages()
Node::preSave in core/modules/node/src/Entity/Node.php

File

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

Class

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

Namespace

Drupal\Core\Entity

Code

public function getTranslationLanguages($include_default = TRUE) {
    $translations = array_filter($this->translations, function ($translation) {
        return $translation['status'];
    });
    unset($translations[LanguageInterface::LANGCODE_DEFAULT]);
    if ($include_default) {
        $translations[$this->defaultLangcode] = TRUE;
    }
    // Now load language objects based upon translation langcodes.
    return array_intersect_key($this->getLanguages(), $translations);
}

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