function EntityResource::delete
Same name in other branches
- 9 core/modules/rest/src/Plugin/rest/resource/EntityResource.php \Drupal\rest\Plugin\rest\resource\EntityResource::delete()
- 8.9.x core/modules/rest/src/Plugin/rest/resource/EntityResource.php \Drupal\rest\Plugin\rest\resource\EntityResource::delete()
- 10 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\ModifiedResourceResponse The HTTP response object.
Throws
\Symfony\Component\HttpKernel\Exception\HttpException
File
-
core/
modules/ rest/ src/ Plugin/ rest/ resource/ EntityResource.php, line 326
Class
- EntityResource
- Represents entities as resources.
Namespace
Drupal\rest\Plugin\rest\resourceCode
public function delete(EntityInterface $entity) {
try {
$entity->delete();
$this->logger
->notice('Deleted entity %type with ID %id.', [
'%type' => $entity->getEntityTypeId(),
'%id' => $entity->id(),
]);
// DELETE responses have an empty body.
return new ModifiedResourceResponse(NULL, 204);
} catch (EntityStorageException $e) {
throw new HttpException(500, 'Internal Server Error', $e);
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.