function View::preDelete

Same name in other branches
  1. 8.9.x core/modules/views/src/Entity/View.php \Drupal\views\Entity\View::preDelete()
  2. 10 core/modules/views/src/Entity/View.php \Drupal\views\Entity\View::preDelete()
  3. 11.x core/modules/views/src/Entity/View.php \Drupal\views\Entity\View::preDelete()

Overrides ConfigEntityBase::preDelete

File

core/modules/views/src/Entity/View.php, line 403

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();
        }
    }
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.