public function ContentEntityBase::getTranslationLanguages in Drupal 8
Same name and namespace in other branches
- 9 core/lib/Drupal/Core/Entity/ContentEntityBase.php \Drupal\Core\Entity\ContentEntityBase::getTranslationLanguages()
Returns the languages the data is translated to.
Parameters
bool $include_default: (optional) Whether the default language should be included. Defaults to TRUE.
Return value
\Drupal\Core\Language\LanguageInterface[] An associative array of language objects, keyed by language codes.
Overrides TranslatableInterface::getTranslationLanguages
1 call to ContentEntityBase::getTranslationLanguages()
- Node::preSave in core/
modules/ node/ src/ Entity/ Node.php - Acts on an entity before the presave hook is invoked.
File
- core/
lib/ Drupal/ Core/ Entity/ ContentEntityBase.php, line 1010
Class
- ContentEntityBase
- Implements Entity Field API specific enhancements to the Entity class.
Namespace
Drupal\Core\EntityCode
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);
}