class EntitySerializationTestHooks

Hook implementations for entity_serialization_test.

Hierarchy

Expanded class hierarchy of EntitySerializationTestHooks

File

core/modules/serialization/tests/modules/entity_serialization_test/src/Hook/EntitySerializationTestHooks.php, line 13

Namespace

Drupal\entity_serialization_test\Hook
View source
class EntitySerializationTestHooks {
    
    /**
     * Implements hook_entity_field_access_alter().
     *
     * Overrides some default access control to support testing.
     *
     * @see Drupal\serialization\Tests\EntitySerializationTest::testUserNormalize()
     */
    public function entityFieldAccessAlter(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());
        }
    }

}

Members

Title Sort descending Modifiers Object type Summary
EntitySerializationTestHooks::entityFieldAccessAlter public function Implements hook_entity_field_access_alter().

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.