To delete a node in Drupal you need to use the storage handler
$nodeStorage = $this->entityTypeManager->getStorage("node");
$nodeStorage->delete([$node]);This is much the same mechanism for deleting any other entity, you just load the storage handler and call the delete method, passing in an array of entity objects you want to delete.
Add new comment