public function RelationshipFieldAccess::access in Drupal 9
Same name and namespace in other branches
- 8 core/modules/jsonapi/src/Access/RelationshipFieldAccess.php \Drupal\jsonapi\Access\RelationshipFieldAccess::access()
Checks access to the relationship field on the given route.
Parameters
\Symfony\Component\HttpFoundation\Request $request: The incoming HTTP request object.
\Symfony\Component\Routing\Route $route: The route to check against.
\Drupal\Core\Session\AccountInterface $account: The currently logged in account.
Return value
\Drupal\Core\Access\AccessResultInterface The access result.
File
- core/
modules/ jsonapi/ src/ Access/ RelationshipFieldAccess.php, line 66
Class
- RelationshipFieldAccess
- Defines a class to check access to related and relationship routes.
Namespace
Drupal\jsonapi\AccessCode
public function access(Request $request, Route $route, AccountInterface $account) {
@trigger_error(sprintf("The %s access check is deprecated in drupal:9.2.0 and is removed from drupal:10.0.0. There is no replacement. JSON:API's route access checks are internal. See https://www.drupal.org/node/3194641.", static::ROUTE_REQUIREMENT_KEY), E_USER_DEPRECATED);
$relationship_route_access_checker = \Drupal::service('access_check.jsonapi.relationship_route_access');
assert($relationship_route_access_checker instanceof RelationshipRouteAccessCheck);
$access_result = $relationship_route_access_checker
->access($route, RouteMatch::createFromRequest($request), $account);
assert($access_result instanceof AccessResultReasonInterface);
if (!$access_result
->isAllowed() && $request
->isMethodCacheable()) {
throw new CacheableAccessDeniedHttpException(CacheableMetadata::createFromObject($access_result), $access_result
->getReason());
}
return $access_result;
}