function translation_views_views_query_substitutions in Translation Views 8
Implements hook_views_query_substitutions().
File
- ./
translation_views.views_execution.inc, line 16 - Provide views runtime hooks for translation_views.module.
Code
function translation_views_views_query_substitutions(ViewExecutable $view) {
$inputs = $view
->getExposedInput();
$langcodes = array_keys(\Drupal::languageManager()
->getLanguages(LanguageInterface::STATE_CONFIGURABLE));
$langcode = $langcode_limit = '';
if (isset($inputs['translation_target_language']) && in_array($inputs['translation_target_language'], $langcodes)) {
$langcode = $langcode_limit = $inputs['translation_target_language'];
}
else {
$langcode = \Drupal::languageManager()
->getDefaultLanguage()
->getId();
}
$substitutions = [
'***TRANSLATION_VIEWS_TARGET_LANG***' => $langcode,
'***TRANSLATION_VIEWS_TARGET_LIMIT_LANG***' => $langcode_limit,
];
return $substitutions;
}