function views_entity_test_entity_field_access in Zircon Profile 8.0
Same name and namespace in other branches
- 8 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 - Contains main module functionality.
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()
->cacheUntilEntityChanges($items
->getEntity());
}
}
}
// No opinion.
return AccessResult::neutral();
}