public function EntityNG::getTranslationLanguages

Implements TranslatableInterface::getTranslationLanguages().

Overrides Entity::getTranslationLanguages

File

drupal/core/lib/Drupal/Core/Entity/EntityNG.php, line 257
Definition of Drupal\Core\Entity\EntityNG.

Class

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

Namespace

Drupal\Core\Entity

Code

public function getTranslationLanguages($include_default = TRUE) {
  $translations = array();

  // Build an array with the translation langcodes set as keys.
  foreach ($this
    ->getProperties() as $name => $property) {
    if (isset($this->values[$name])) {
      $translations += $this->values[$name];
    }
    $translations += $this->fields[$name];
  }
  unset($translations[LANGUAGE_DEFAULT]);
  if ($include_default) {
    $translations[$this
      ->language()->langcode] = TRUE;
  }

  // Now get languages based upon translation langcodes. Empty languages must
  // be filtered out as they concern empty/unset properties.
  $languages = array_intersect_key(language_list(LANGUAGE_ALL), array_filter($translations));
  return $languages;
}