You are here

protected function ContentEntity::getLanguages in Search API 8

Retrieves the enabled languages.

Return value

\Drupal\Core\Language\LanguageInterface[] All languages that are enabled for this datasource, keyed by language code.

3 calls to ContentEntity::getLanguages()
ContentEntity::getAffectedItemsForEntityChange in src/Plugin/search_api/datasource/ContentEntity.php
Identifies items affected by a change to a referenced entity.
ContentEntity::getPartialItemIds in src/Plugin/search_api/datasource/ContentEntity.php
ContentEntity::loadMultiple in src/Plugin/search_api/datasource/ContentEntity.php
Loads multiple items.

File

src/Plugin/search_api/datasource/ContentEntity.php, line 972

Class

ContentEntity
Represents a datasource which exposes the content entities.

Namespace

Drupal\search_api\Plugin\search_api\datasource

Code

protected function getLanguages() {
  $all_languages = $this
    ->getLanguageManager()
    ->getLanguages();
  if ($this
    ->isTranslatable()) {
    $selected_languages = array_flip($this->configuration['languages']['selected']);
    if ($this->configuration['languages']['default']) {
      return array_diff_key($all_languages, $selected_languages);
    }
    else {
      return array_intersect_key($all_languages, $selected_languages);
    }
  }
  return $all_languages;
}