You are here

public static function Feed::postDelete in Drupal 8

Same name and namespace in other branches
  1. 9 core/modules/aggregator/src/Entity/Feed.php \Drupal\aggregator\Entity\Feed::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 EntityBase::postDelete

File

core/modules/aggregator/src/Entity/Feed.php, line 119

Class

Feed
Defines the aggregator feed entity class.

Namespace

Drupal\aggregator\Entity

Code

public static function postDelete(EntityStorageInterface $storage, array $entities) {
  parent::postDelete($storage, $entities);
  if (\Drupal::moduleHandler()
    ->moduleExists('block')) {

    // Make sure there are no active blocks for these feeds.
    $ids = \Drupal::entityQuery('block')
      ->condition('plugin', 'aggregator_feed_block')
      ->condition('settings.feed', array_keys($entities))
      ->execute();
    if ($ids) {
      $block_storage = \Drupal::entityTypeManager()
        ->getStorage('block');
      $block_storage
        ->delete($block_storage
        ->loadMultiple($ids));
    }
  }
}