public function EntityResource::delete in Zircon Profile 8
Same name and namespace in other branches
- 8.0 core/modules/rest/src/Plugin/rest/resource/EntityResource.php \Drupal\rest\Plugin\rest\resource\EntityResource::delete()
Responds to entity DELETE requests.
Parameters
\Drupal\Core\Entity\EntityInterface $entity: The entity object.
Return value
\Drupal\rest\ResourceResponse The HTTP response object.
Throws
\Symfony\Component\HttpKernel\Exception\HttpException
File
- core/
modules/ rest/ src/ Plugin/ rest/ resource/ EntityResource.php, line 187 - Contains \Drupal\rest\Plugin\rest\resource\EntityResource.
Class
- EntityResource
- Represents entities as resources.
Namespace
Drupal\rest\Plugin\rest\resourceCode
public function delete(EntityInterface $entity) {
if (!$entity
->access('delete')) {
throw new AccessDeniedHttpException();
}
try {
$entity
->delete();
$this->logger
->notice('Deleted entity %type with ID %id.', array(
'%type' => $entity
->getEntityTypeId(),
'%id' => $entity
->id(),
));
// Delete responses have an empty body.
return new ResourceResponse(NULL, 204);
} catch (EntityStorageException $e) {
throw new HttpException(500, 'Internal Server Error', $e);
}
}