search_api-8.x-1.15/tests/search_api_test/search_api_test.module

tests/search_api_test/search_api_test.module
<?php

/**
 * @file
 * Provides a fake search server and other help for testing purposes.
 */

use Drupal\Core\Session\AccountInterface;
use Drupal\node\NodeInterface;

/**
 * Implement hook_node_grants().
 */
function search_api_test_node_grants(AccountInterface $account, $op) {
  $grants = [];

  if (\Drupal::state()->get('search_api_test_add_node_access_grant', TRUE)) {
    $grants['search_api_test'] = [$account->id()];
  }

  return $grants;
}

/**
 * Implement hook_node_access_records().
 */
function search_api_test_node_access_records(NodeInterface $node) {
  $grants = [];

  if (\Drupal::state()->get('search_api_test_add_node_access_grant', TRUE)) {
    $grants[] = [
      'realm' => 'search_api_test',
      'gid' => $node->getOwnerId(),
      'grant_view' => 1,
      'grant_update' => 0,
      'grant_delete' => 0,
      'langcode' => $node->language()->getId(),
    ];
  }

  return $grants;
}

Главная | Обратная связь

drupal hosting | друпал хостинг | it patrol .inc