entity_serialization_test.module in Drupal 8
Same filename and directory in other branches
Test support module for entity serialization tests.
File
core/modules/serialization/tests/modules/entity_serialization_test/entity_serialization_test.moduleView source
<?php
/**
* @file
* Test support module for entity serialization tests.
*/
use Drupal\Core\Access\AccessResult;
/**
* Implements hook_entity_field_access_alter().
*
* Overrides some default access control to support testing.
*
* @see Drupal\serialization\Tests\EntitySerializationTest::testUserNormalize()
*/
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());
}
}
Functions
Name | Description |
---|---|
entity_serialization_test_entity_field_access_alter | Implements hook_entity_field_access_alter(). |