search_api_test_views.module 773 B

123456789101112131415161718192021222324252627
  1. <?php
  2. /**
  3. * @file
  4. * Contains hook implementations for the Search API Views Test module.
  5. */
  6. use Drupal\search_api\Query\QueryInterface;
  7. /**
  8. * Implements hook_search_api_query_alter().
  9. *
  10. * Prints the contents of the "search_api_retrieved_properties" query option to
  11. * the page (if present) so it can be checked by the testing code.
  12. */
  13. function search_api_test_views_search_api_query_alter(QueryInterface $query) {
  14. $properties = $query->getOption('search_api_retrieved_properties');
  15. if ($properties) {
  16. $message = [];
  17. foreach ($properties as $datasource_properties) {
  18. foreach ($datasource_properties as $combined_property_path) {
  19. $message[] = "'$combined_property_path'";
  20. }
  21. }
  22. drupal_set_message(implode(' ', $message));
  23. }
  24. }