public static function Poll::postDelete in Poll 8
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 EntityBase::postDelete
File
- src/
Entity/ Poll.php, line 452
Class
- Poll
- Defines the poll entity class.
Namespace
Drupal\poll\EntityCode
public static function postDelete(EntityStorageInterface $storage, array $entities) {
parent::postDelete($storage, $entities);
// Delete votes.
foreach ($entities as $entity) {
$storage
->deleteVotes($entity);
}
// Delete referenced choices.
$choices = [];
foreach ($entities as $entity) {
$choices = array_merge($choices, $entity->choice
->referencedEntities());
}
if ($choices) {
\Drupal::entityTypeManager()
->getStorage('poll_choice')
->delete($choices);
}
}