public function EntityResource::getIndividual in JSON:API 8
Same name and namespace in other branches
- 8.2 src/Controller/EntityResource.php \Drupal\jsonapi\Controller\EntityResource::getIndividual()
Gets the individual entity.
Parameters
\Drupal\Core\Entity\EntityInterface $entity: The loaded entity.
\Symfony\Component\HttpFoundation\Request $request: The request object.
int $response_code: The response code. Defaults to 200.
Return value
\Drupal\jsonapi\ResourceResponse The response.
1 call to EntityResource::getIndividual()
- EntityResource::getRelated in src/
Controller/ EntityResource.php - Gets the related resource.
File
- src/
Controller/ EntityResource.php, line 139
Class
- EntityResource
- Process all entity requests.
Namespace
Drupal\jsonapi\ControllerCode
public function getIndividual(EntityInterface $entity, Request $request, $response_code = 200) {
$entity_access = $entity
->access('view', NULL, TRUE);
if (!$entity_access
->isAllowed()) {
throw new EntityAccessDeniedHttpException($entity, $entity_access, '/data', 'The current user is not allowed to GET the selected resource.');
}
$response = $this
->buildWrappedResponse($entity, $response_code);
$response
->addCacheableDependency($entity_access);
return $response;
}