示例#1
0
/**
 * Alter the query before executing the query.
 *
 * @param \Drupal\views\ViewExecutable $view
 *   The view object about to be processed.
 * @param \Drupal\search_api\Query\QueryInterface $query
 *   The Search API Views query to be altered.
 *
 * @deprecated Use hook_views_query_alter() instead.
 *
 * @see hook_views_query_alter()
 *
 * @todo Possibly remove this, since hook_views_query_alter() works just as well
 *   (with instanceof check and $query->getSearchApiQuery()).
 */
function hook_search_api_views_query_alter(\Drupal\views\ViewExecutable $view, \Drupal\search_api\Query\QueryInterface &$query) {
  if ($view->getPath() === 'search') {
    $query->setOption('custom_do_magic', TRUE);
  }
}