hook_language_fallback_candidates_OPERATION_alter(array &$candidates, array $context)
Allow modules to alter the fallback candidates for specific operations.
Parameters
array $candidates: An array of language codes whose order will determine the language fallback order.
array $context: A language fallback context.
See also
\Drupal\Core\Language\LanguageManagerInterface::getFallbackCandidates()
Related topics
- Hooks
- Define functions that alter the behavior of Drupal core.
File
- core/modules/language/language.api.php, line 106
- Hooks provided by the Language module.
Code
function hook_language_fallback_candidates_OPERATION_alter(array &$candidates, array $context) { // We know that the current OPERATION deals with entities so no need to check // here. if ($context['data']->getEntityTypeId() == 'node') { $candidates = array_reverse($candidates); } }
Please login to continue.