function views_entity_test_entity_field_access
Same name in other branches
- 8.9.x core/modules/views/tests/modules/views_entity_test/views_entity_test.module \views_entity_test_entity_field_access()
- 10 core/modules/views/tests/modules/views_entity_test/views_entity_test.module \views_entity_test_entity_field_access()
- 11.x core/modules/views/tests/modules/views_entity_test/views_entity_test.module \views_entity_test_entity_field_access()
Implements hook_entity_field_access().
See also
\Drupal\system\Tests\Entity\FieldAccessTest::testFieldAccess()
File
-
core/
modules/ views/ tests/ modules/ views_entity_test/ views_entity_test.module, line 37
Code
function views_entity_test_entity_field_access($operation, FieldDefinitionInterface $field_definition, AccountInterface $account, FieldItemListInterface $items = NULL) {
if ($field_definition->getName() == 'test_text_access') {
if ($items) {
if ($items->value == 'no access value') {
return AccessResult::forbidden()->addCacheableDependency($items->getEntity());
}
}
}
// No opinion.
return AccessResult::neutral();
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.