public function CommentStorage::delete in Multiversion 8
Same name and namespace in other branches
- 8.2 src/Entity/Storage/Sql/CommentStorage.php \Drupal\multiversion\Entity\Storage\Sql\CommentStorage::delete()
Deletes permanently saved entities.
Parameters
array $entities: An array of entity objects to delete.
Throws
\Drupal\Core\Entity\EntityStorageException In case of failures, an exception is thrown.
Overrides SqlContentEntityStorage::delete
File
- src/
Entity/ Storage/ Sql/ CommentStorage.php, line 21
Class
- CommentStorage
- Storage handler for comments.
Namespace
Drupal\multiversion\Entity\Storage\SqlCode
public function delete(array $entities) {
// Ensure that the entities are keyed by ID.
$keyed_entities = [];
foreach ($entities as $entity) {
$keyed_entities[$entity
->id()] = $entity;
}
// Delete received comments and all their children.
if (!empty($keyed_entities)) {
$child_cids = $this
->getChildCids($keyed_entities);
while (!empty($child_cids)) {
$child_entities = $this
->loadMultiple($child_cids);
$keyed_entities = $keyed_entities + $child_entities;
$child_cids = $this
->getChildCids($child_entities);
}
}
// Sort the array with entities descending to delete children before their
// parents.
krsort($keyed_entities);
$this
->deleteEntities($keyed_entities);
}