public ViewsEntitySchemaSubscriber::onEntityTypeDelete(EntityTypeInterface $entity_type)
Reacts to the deletion of the entity type.
Parameters
\Drupal\Core\Entity\EntityTypeInterface $entity_type: The entity type being deleted.
Overrides EntityTypeEventSubscriberTrait::onEntityTypeDelete
File
- core/modules/views/src/EventSubscriber/ViewsEntitySchemaSubscriber.php, line 197
Class
- ViewsEntitySchemaSubscriber
- Reacts to changes on entity types to update all views entities.
Namespace
Drupal\views\EventSubscriber
Code
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | public function onEntityTypeDelete(EntityTypeInterface $entity_type ) { $tables = [ $entity_type ->getBaseTable(), $entity_type ->getDataTable(), $entity_type ->getRevisionTable(), $entity_type ->getRevisionDataTable(), ]; $all_views = $this ->entityManager->getStorage( 'view' )->loadMultiple(NULL); /** @var \Drupal\views\Entity\View $view */ foreach ( $all_views as $id => $view ) { // First check just the base table. if (in_array( $view ->get( 'base_table' ), $tables )) { $view ->disable(); $view ->save(); } } } |
Please login to continue.