You are here

function search_api_test_views_entity_operation in Search API 8

Implements hook_entity_operation().

File

tests/search_api_test_views/search_api_test_views.module, line 52
Contains hook implementations for the Search API Views Test module.

Code

function search_api_test_views_entity_operation(EntityInterface $entity) {
  if ($entity
    ->getEntityTypeId() !== 'entity_test_mulrev_changed') {
    return [];
  }

  // For testing purpose we want to have one entity without operations.
  if ($entity
    ->id() == 2) {
    return [];
  }
  $operations['edit'] = [
    'title' => t('Edit'),
    'url' => $entity
      ->toUrl('edit-form'),
    'weight' => 0,
  ];
  $operations['delete'] = [
    'title' => t('Delete'),
    'url' => $entity
      ->toUrl('delete-form'),
    'weight' => 1,
  ];
  return $operations;
}