EntityAccessChecker
class EntityAccessChecker (View source)
| internal | JSON:API maintains no PHP API. The API is the HTTP API. This class may change at any time and could break any dependencies on it. |
Checks access to entities.
JSON:API needs to check access to every single entity type. Some entity types have non-standard access checking logic. This class centralizes entity access checking logic.
Properties
| protected ResourceTypeRepositoryInterface | $resourceTypeRepository | The JSON:API resource type repository. |
|
| protected RouterInterface | $router | The router. |
|
| protected AccountInterface | $currentUser | The current user. |
|
| protected EntityRepositoryInterface | $entityRepository | The entity repository. |
|
| protected NodeRevisionAccessCheck|null | $nodeRevisionAccessCheck | The node revision access check service. |
|
| protected MediaRevisionAccessCheck|null | $mediaRevisionAccessCheck | The media revision access check service. |
|
| protected LatestRevisionCheck | $latestRevisionCheck | The latest revision check service. |
Methods
EntityAccessChecker constructor.
Sets the node revision access check service.
Sets the media revision access check service.
Sets the media revision access check service.
Get the object to normalize and the access based on the provided entity.
Checks access to the given entity.
Checks access to the given revision entity.
Details
__construct(ResourceTypeRepositoryInterface $resource_type_repository, RouterInterface $router, AccountInterface $account, EntityRepositoryInterface $entity_repository)
EntityAccessChecker constructor.
setNodeRevisionAccessCheck(NodeRevisionAccessCheck $node_revision_access_check)
Sets the node revision access check service.
This is only called when node module is installed.
setMediaRevisionAccessCheck(MediaRevisionAccessCheck $media_revision_access_check)
Sets the media revision access check service.
This is only called when media module is installed.
setLatestRevisionCheck(LatestRevisionCheck $latest_revision_check)
Sets the media revision access check service.
This is only called when content_moderation module is installed.
ResourceObject|LabelOnlyResourceObject|EntityAccessDeniedHttpException
getAccessCheckedResourceObject(EntityInterface $entity, AccountInterface $account = NULL)
Get the object to normalize and the access based on the provided entity.
AccessResultInterface|AccessResultReasonInterface
checkEntityAccess(EntityInterface $entity, string $operation, AccountInterface $account)
Checks access to the given entity.
protected AccessResultInterface|AccessResultReasonInterface
checkRevisionViewAccess(EntityInterface $entity, AccountInterface $account)
Checks access to the given revision entity.
This should only be called for non-default revisions.
There is no standardized API for revision access checking in Drupal core and this method shims that missing API.