trait TranslationViewsTargetLanguage in Translation Views 8
Trait TranslationViewsTargetLanguage.
Used to give ability to get selected target langcode, used by different different fields, filters.
@package Drupal\translation_views
Hierarchy
- trait \Drupal\translation_views\TranslationViewsTargetLanguage
5 files declare their use of TranslationViewsTargetLanguage
- TranslationModerationState.php in src/
Plugin/ views/ field/ TranslationModerationState.php - TranslationOperationsField.php in src/
Plugin/ views/ field/ TranslationOperationsField.php - TranslationStatus.php in src/
Plugin/ views/ field/ TranslationStatus.php - TranslationTargetLanguageField.php in src/
Plugin/ views/ field/ TranslationTargetLanguageField.php - TranslationTargetLanguageFilter.php in src/
Plugin/ views/ filter/ TranslationTargetLanguageFilter.php
File
- src/
TranslationViewsTargetLanguage.php, line 15
Namespace
Drupal\translation_viewsView source
trait TranslationViewsTargetLanguage {
/**
* The language manager.
*
* @var \Drupal\Core\Language\LanguageManagerInterface
*/
protected $languageManager;
/**
* Target exposed key.
*
* @var string
*/
public static $targetExposedKey = 'translation_target_language';
/**
* Get target language from exposed input.
*
* @return string
* The selected target langcode.
*/
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;
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
TranslationViewsTargetLanguage:: |
protected | property | The language manager. | |
TranslationViewsTargetLanguage:: |
public static | property | Target exposed key. | |
TranslationViewsTargetLanguage:: |
protected | function | Get target language from exposed input. |