function entity_test_entity_field_access_alter

Implements hook_entity_field_access_alter().

See also

\Drupal\system\Tests\Entity\FieldAccessTest::testFieldAccess()

File

drupal/core/modules/system/tests/modules/entity_test/entity_test.module, line 384
Test module for the entity API providing several entity types for testing.

Code

function entity_test_entity_field_access_alter(array &$grants, array $context) {
  $field = $context['field'];
  if ($field
    ->getName() == 'field_test_text' && $field->value == 'access alter value') {
    $grants[':default'] = FALSE;
  }
}