You are here

public static function MessageQueueItem::preDelete in Courier 8

Same name and namespace in other branches
  1. 2.x src/Entity/MessageQueueItem.php \Drupal\courier\Entity\MessageQueueItem::preDelete()

Acts on entities before they are deleted and before hooks are invoked.

Used before the entities are deleted and 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::preDelete

File

src/Entity/MessageQueueItem.php, line 139

Class

MessageQueueItem
Defines a Message queue item entity.

Namespace

Drupal\courier\Entity

Code

public static function preDelete(EntityStorageInterface $storage, array $entities) {

  /** @var static[] $entities */
  foreach ($entities as $message_queue_item) {

    // Delete messages attached to this queue item.
    foreach ($message_queue_item
      ->getMessages() as $message) {
      $message
        ->delete();
    }
  }
  parent::preDelete($storage, $entities);
}