Same name and namespace in other branches
  1. 9 core/modules/block_content/src/Entity/BlockContent.php \Drupal\block_content\Entity\BlockContent::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 EntityInterface::preDelete

File

core/modules/block_content/src/Entity/BlockContent.php, line 141

Class

BlockContent
Defines the content block entity class.

Namespace

Drupal\block_content\Entity

Code

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

  /** @var \Drupal\block_content\BlockContentInterface $block */
  foreach ($entities as $block) {
    foreach ($block
      ->getInstances() as $instance) {
      $instance
        ->delete();
    }
  }
}