function node_access_test_language_node_access_records

Implements hook_node_access_records().

File

drupal/core/modules/node/tests/modules/node_access_test_language/node_access_test_language.module, line 26
Test module with a language-aware node access implementation.

Code

function node_access_test_language_node_access_records(EntityInterface $node) {
  $grants = array();

  // Create grants for each translation of the node.
  foreach ($node
    ->getTranslationLanguages() as $langcode => $language) {

    // If the translation is not marked as private, grant access.
    $grants[] = array(
      'realm' => 'node_access_language_test',
      'gid' => 7888,
      'grant_view' => empty($node->field_private[$langcode][0]['value']) ? 1 : 0,
      'grant_update' => 0,
      'grant_delete' => 0,
      'priority' => 0,
      'langcode' => $langcode,
    );
  }
  return $grants;
}