function ResourceTestBase::entityFieldAccess
Same name in other branches
- 9 core/modules/jsonapi/tests/src/Functional/ResourceTestBase.php \Drupal\Tests\jsonapi\Functional\ResourceTestBase::entityFieldAccess()
- 8.9.x core/modules/jsonapi/tests/src/Functional/ResourceTestBase.php \Drupal\Tests\jsonapi\Functional\ResourceTestBase::entityFieldAccess()
- 11.x core/modules/jsonapi/tests/src/Functional/ResourceTestBase.php \Drupal\Tests\jsonapi\Functional\ResourceTestBase::entityFieldAccess()
Checks access for the given field operation on the given entity.
Parameters
\Drupal\Core\Entity\EntityInterface $entity: The entity for which to check field access.
string $field_name: The field for which to check access.
string $operation: The operation for which to check access.
\Drupal\Core\Session\AccountInterface $account: The account for which to check access.
Return value
\Drupal\Core\Access\AccessResultInterface The AccessResult.
4 calls to ResourceTestBase::entityFieldAccess()
- ResourceTestBase::doTestRelationshipMutation in core/
modules/ jsonapi/ tests/ src/ Functional/ ResourceTestBase.php - Performs one round of relationship POST, PATCH and DELETE route testing.
- ResourceTestBase::getExpectedCollectionCacheability in core/
modules/ jsonapi/ tests/ src/ Functional/ ResourceTestBase.php - Computes the cacheability for a given entity collection.
- ResourceTestBase::getExpectedGetRelationshipResponse in core/
modules/ jsonapi/ tests/ src/ Functional/ ResourceTestBase.php - Gets an expected ResourceResponse for the given relationship.
- ResourceTestBase::getExpectedRelatedResponse in core/
modules/ jsonapi/ tests/ src/ Functional/ ResourceTestBase.php - Builds an expected related ResourceResponse for the given field.
File
-
core/
modules/ jsonapi/ tests/ src/ Functional/ ResourceTestBase.php, line 3456
Class
- ResourceTestBase
- Subclass this for every JSON:API resource type.
Namespace
Drupal\Tests\jsonapi\FunctionalCode
protected static function entityFieldAccess(EntityInterface $entity, $field_name, $operation, AccountInterface $account) {
$entity_access = static::entityAccess($entity, $operation === 'edit' ? 'update' : 'view', $account);
$field_access = $entity->{$field_name}
->access($operation, $account, TRUE);
return $entity_access->andIf($field_access);
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.