public function EntityResource::getIndividual in Drupal 9
Same name and namespace in other branches
- 8 core/modules/jsonapi/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.
Return value
\Drupal\jsonapi\ResourceResponse The response.
Throws
\Drupal\jsonapi\Exception\EntityAccessDeniedHttpException Thrown when access to the entity is not allowed.
File
- core/
modules/ jsonapi/ src/ Controller/ EntityResource.php, line 208
Class
- EntityResource
- Process all entity requests.
Namespace
Drupal\jsonapi\ControllerCode
public function getIndividual(EntityInterface $entity, Request $request) {
$resource_object = $this->entityAccessChecker
->getAccessCheckedResourceObject($entity);
if ($resource_object instanceof EntityAccessDeniedHttpException) {
throw $resource_object;
}
$primary_data = new ResourceObjectData([
$resource_object,
], 1);
$response = $this
->buildWrappedResponse($primary_data, $request, $this
->getIncludes($request, $primary_data));
return $response;
}