public function Translator::getSupportedLanguagePairs

Gets the supported language pairs for this translator.

Return value

array List of language pairs where a pair is an associative array of source_language and target_language. Example: array( array('source_language' => 'en-US', 'target_language' => 'de-DE'), array('source_language' => 'en-US', 'target_language' => 'de-CH'), )

Overrides TranslatorInterface::getSupportedLanguagePairs

File

src/Entity/Translator.php, line 316

Class

Translator
Entity class for the tmgmt_translator entity.

Namespace

Drupal\tmgmt\Entity

Code

public function getSupportedLanguagePairs() {
  if ($plugin = $this
    ->getPlugin()) {
    $info = $plugin
      ->getPluginDefinition();
    if (isset($info['language_cache']) && empty($info['language_cache'])) {

      // This plugin doesn't support language caching.
      return $plugin
        ->getSupportedLanguagePairs($this);
    }
    else {

      // Retrieve the supported languages from the cache.
      if (empty($this->languagePairsCache) && ($cache = \Drupal::cache('data')
        ->get('tmgmt_language_pairs:' . $this->name))) {
        $this->languagePairsCache = $cache->data;
      }

      // Even if we successfully queried the cache data might not be yet
      // available.
      if (empty($this->languagePairsCache)) {
        $this->languagePairsCache = $plugin
          ->getSupportedLanguagePairs($this);
        $this
          ->updateCache();
      }
    }
    return $this->languagePairsCache;
  }
}