You are here

public static function View::preDelete in Zircon Profile 8.0

Same name and namespace in other branches
  1. 8 core/modules/views/src/Entity/View.php \Drupal\views\Entity\View::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 ConfigEntityBase::preDelete

File

core/modules/views/src/Entity/View.php, line 402
Contains \Drupal\views\Entity\View.

Class

View
Defines a View configuration entity class.

Namespace

Drupal\views\Entity

Code

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

  // Call the remove() hook on the individual displays.

  /** @var \Drupal\views\ViewEntityInterface $entity */
  foreach ($entities as $entity) {
    $executable = Views::executableFactory()
      ->get($entity);
    foreach ($entity
      ->get('display') as $display_id => $display) {
      $executable
        ->setDisplay($display_id);
      $executable
        ->getDisplay()
        ->remove();
    }
  }
}