public function EntityResource::deleteIndividual in JSON:API 8
Same name and namespace in other branches
- 8.2 src/Controller/EntityResource.php \Drupal\jsonapi\Controller\EntityResource::deleteIndividual()
Deletes an 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\Core\Entity\EntityStorageException
\Drupal\jsonapi\Exception\EntityAccessDeniedHttpException
File
- src/
Controller/ EntityResource.php, line 336
Class
- EntityResource
- Process all entity requests.
Namespace
Drupal\jsonapi\ControllerCode
public function deleteIndividual(EntityInterface $entity, Request $request) {
$entity_access = $entity
->access('delete', NULL, TRUE);
if (!$entity_access
->isAllowed()) {
throw new EntityAccessDeniedHttpException($entity, $entity_access, '/data', 'The current user is not allowed to DELETE the selected resource.');
}
$entity
->delete();
return new ResourceResponse(NULL, 204);
}