function entity_test_entity_field_access_alter
Same name in other branches
- 9 core/modules/system/tests/modules/entity_test/entity_test.module \entity_test_entity_field_access_alter()
- 10 core/modules/system/tests/modules/entity_test/entity_test.module \entity_test_entity_field_access_alter()
Implements hook_entity_field_access_alter().
See also
\Drupal\system\Tests\Entity\FieldAccessTest::testFieldAccess()
File
-
core/
modules/ system/ tests/ modules/ entity_test/ entity_test.module, line 525
Code
function entity_test_entity_field_access_alter(array &$grants, array $context) {
if ($context['field_definition']->getName() == 'field_test_text' && $context['items']->value == 'access alter value') {
$grants[':default'] = AccessResult::forbidden()->inheritCacheability($grants[':default'])
->addCacheableDependency($context['items']->getEntity());
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.