TranslationViewsTargetLanguage.php in Translation Views 8
File
src/TranslationViewsTargetLanguage.php
View source
<?php
namespace Drupal\translation_views;
use Drupal\views\Plugin\views\PluginBase;
trait TranslationViewsTargetLanguage {
protected $languageManager;
public static $targetExposedKey = 'translation_target_language';
protected function getTargetLangcode() {
$inputs = $this->view
->getExposedInput();
$langcode = isset($inputs[self::$targetExposedKey]) ? $inputs[self::$targetExposedKey] : PluginBase::VIEWS_QUERY_LANGUAGE_SITE_DEFAULT;
return $langcode == PluginBase::VIEWS_QUERY_LANGUAGE_SITE_DEFAULT ? $this->languageManager
->getDefaultLanguage()
->getId() : $langcode;
}
}