You are here

public function CoreSearchService::search in Fast Autocomplete 7

Implements SearchServiceInterface::search().

Parameters

string $key: The key to use in the search.

string $language: The language to use in the search.

Return value

array The results array containing the resulting nids.

Overrides AbstractSearchService::search

File

src/SearchService/CoreSearchService.php, line 21

Class

CoreSearchService
Fast Autocomplete backend service class providing Drupal core search.

Namespace

Drupal\fac\SearchService

Code

public function search($key, $language) {
  $result = array();
  $search_results = module_invoke('node', 'search_execute', $key, NULL);

  // Only return the configured amount of results.
  $search_results = array_slice($search_results, 0, isset($settings['number_of_results']) ? $settings['number_of_results'] : 5);
  foreach ($search_results as $sr) {
    $result['items'][] = array(
      'entity_type' => 'node',
      'etid' => $sr['node']->nid,
    );
  }
  return $result;
}