function media_library_test_entity_field_access
Same name in other branches
- 9 core/modules/media_library/tests/modules/media_library_test/media_library_test.module \media_library_test_entity_field_access()
- 8.9.x core/modules/media_library/tests/modules/media_library_test/media_library_test.module \media_library_test_entity_field_access()
- 11.x core/modules/media_library/tests/modules/media_library_test/media_library_test.module \media_library_test_entity_field_access()
Implements hook_entity_field_access().
File
-
core/
modules/ media_library/ tests/ modules/ media_library_test/ media_library_test.module, line 29
Code
function media_library_test_entity_field_access($operation, FieldDefinitionInterface $field_definition, AccountInterface $account, ?FieldItemListInterface $items = NULL) {
$deny_fields = \Drupal::state()->get('media_library_test_entity_field_access_deny_fields', []);
// Always deny the field_media_no_access field.
$deny_fields[] = 'field_media_no_access';
return AccessResult::forbiddenIf(in_array($field_definition->getName(), $deny_fields, TRUE), 'Field access denied by test module');
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.