You are here

function search_api_autocomplete_entity_operation in Search API Autocomplete 8

Implements hook_entity_operation().

File

./search_api_autocomplete.module, line 39
Adds autocomplete capabilities for Search API searches.

Code

function search_api_autocomplete_entity_operation(EntityInterface $entity) {
  if ($entity
    ->getEntityTypeId() != 'search_api_index') {
    return [];
  }
  $operations = [];
  $operations['autocomplete'] = [
    'title' => t('Autocomplete'),
    'weight' => 30,
    'url' => Url::fromRoute('search_api_autocomplete.admin_overview', [
      'search_api_index' => $entity
        ->id(),
    ]),
  ];
  return $operations;
}