public static function Term::postDelete in Zircon Profile 8
Same name and namespace in other branches
- 8.0 core/modules/taxonomy/src/Entity/Term.php \Drupal\taxonomy\Entity\Term::postDelete()
Acts on deleted entities before the delete hook is invoked.
Used after the entities are deleted but before invoking the delete hook.
Parameters
\Drupal\Core\Entity\EntityStorageInterface $storage: The entity storage object.
\Drupal\Core\Entity\EntityInterface[] $entities: An array of entities.
Overrides Entity::postDelete
File
- core/
modules/ taxonomy/ src/ Entity/ Term.php, line 65 - Contains \Drupal\taxonomy\Entity\Term.
Class
- Term
- Defines the taxonomy term entity.
Namespace
Drupal\taxonomy\EntityCode
public static function postDelete(EntityStorageInterface $storage, array $entities) {
parent::postDelete($storage, $entities);
// See if any of the term's children are about to be become orphans.
$orphans = array();
foreach (array_keys($entities) as $tid) {
if ($children = $storage
->loadChildren($tid)) {
foreach ($children as $child) {
// If the term has multiple parents, we don't delete it.
$parents = $storage
->loadParents($child
->id());
if (empty($parents)) {
$orphans[] = $child
->id();
}
}
}
}
// Delete term hierarchy information after looking up orphans but before
// deleting them so that their children/parent information is consistent.
$storage
->deleteTermHierarchy(array_keys($entities));
if (!empty($orphans)) {
entity_delete_multiple('taxonomy_term', $orphans);
}
}