You are here

search_api_test_language_fallback.module in Search API 8

Provides a language fallback for tests.

File

tests/search_api_test_language_fallback/search_api_test_language_fallback.module
View source
<?php

/**
 * @file
 * Provides a language fallback for tests.
 */

/**
 * Implements hook_language_fallback_candidates_alter().
 */
function search_api_test_language_fallback_language_fallback_candidates_alter(array &$candidates, array $context) {
  $attempted_langcode = $context['langcode'];
  $candidates = [
    $attempted_langcode => $attempted_langcode,
  ];
  if ($attempted_langcode === 'fr') {
    $candidates['es'] = 'es';
  }
}