function hook_language_fallback_candidates_OPERATION_alter in Drupal 8
Same name and namespace in other branches
- 9 core/modules/language/language.api.php \hook_language_fallback_candidates_OPERATION_alter()
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
3 functions implement hook_language_fallback_candidates_OPERATION_alter()
Note: this list is generated by pattern matching, so it may include some functions that are not actually implementations of this hook.
- content_translation_language_fallback_candidates_entity_view_alter in core/
modules/ content_translation/ content_translation.module - Implements hook_language_fallback_candidates_OPERATION_alter().
- language_test_language_fallback_candidates_test_alter in core/
modules/ language/ tests/ language_test/ language_test.module - Implements hook_language_fallback_candidates_OPERATION_alter().
- locale_test_language_fallback_candidates_locale_lookup_alter in core/
modules/ locale/ tests/ modules/ locale_test/ locale_test.module - Implements hook_language_fallback_candidates_OPERATION_alter().
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);
}
}