function entity_serialization_test_entity_field_access_alter
Same name in other branches
- 9 core/modules/serialization/tests/modules/entity_serialization_test/entity_serialization_test.module \entity_serialization_test_entity_field_access_alter()
- 10 core/modules/serialization/tests/modules/entity_serialization_test/entity_serialization_test.module \entity_serialization_test_entity_field_access_alter()
- 11.x core/modules/serialization/tests/modules/entity_serialization_test/entity_serialization_test.module \entity_serialization_test_entity_field_access_alter()
Implements hook_entity_field_access_alter().
Overrides some default access control to support testing.
See also
Drupal\serialization\Tests\EntitySerializationTest::testUserNormalize()
File
-
core/
modules/ serialization/ tests/ modules/ entity_serialization_test/ entity_serialization_test.module, line 17
Code
function entity_serialization_test_entity_field_access_alter(array &$grants, array $context) {
// Override default access control from UserAccessControlHandler to allow
// access to 'pass' field for the test user.
if ($context['field_definition']->getName() == 'pass' && $context['account']->getAccountName() == 'serialization_test_user') {
$grants[':default'] = AccessResult::allowed()->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.