search_api_test.module 697 B

123456789101112131415161718192021222324252627282930313233
  1. <?php
  2. /**
  3. * @file
  4. * Provides a fake search server and other help for testing purposes.
  5. */
  6. use Drupal\Core\Session\AccountInterface;
  7. use Drupal\node\NodeInterface;
  8. /**
  9. * Implement hook_node_grants().
  10. */
  11. function search_api_test_node_grants(AccountInterface $account, $op) {
  12. $grants['search_api_test'] = [$account->id()];
  13. return $grants;
  14. }
  15. /**
  16. * Implement hook_node_access_records().
  17. */
  18. function search_api_test_node_access_records(NodeInterface $node) {
  19. $grants[] = [
  20. 'realm' => 'search_api_test',
  21. 'gid' => $node->getOwnerId(),
  22. 'grant_view' => 1,
  23. 'grant_update' => 0,
  24. 'grant_delete' => 0,
  25. 'langcode' => $node->language()->getId(),
  26. ];
  27. return $grants;
  28. }