View::preDelete

public static View::preDelete(EntityStorageInterface $storage, array $entities)

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 397

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();
    }
  }
}
doc_Drupal
2016-10-29 09:53:42
Comments
Leave a Comment

Please login to continue.