diff --git a/core/modules/views/src/Entity/View.php b/core/modules/views/src/Entity/View.php index 34b4ab0..5ed72ef 100644 --- a/core/modules/views/src/Entity/View.php +++ b/core/modules/views/src/Entity/View.php @@ -442,6 +442,35 @@ public function isInstallable() { /** * {@inheritdoc} */ + public function onDependencyRemoval(array $dependencies) { + $changed = parent::onDependencyRemoval($dependencies); + foreach ($dependencies['config'] as $entity) { + if ($entity->getEntityTypeId() == 'field_storage_config') { + foreach (array_keys($this->get('display')) as $display_id) { + $display = &$this->getDisplay($display_id); + // Check if the field is being used on each handler type and if + // necessary remove it. + foreach (Views::getHandlerTypes() as $handler_type) { + $handler_type = $handler_type['plural']; + if (!isset($display['display_options'][$handler_type])) { + continue; + } + foreach ($display['display_options'][$handler_type] as $id => $handler_config) { + if (strpos($id, $entity->getName()) === 0) { + unset($display['display_options'][$handler_type][$id]); + $changed = TRUE; + } + } + } + } + } + } + return $changed; + } + + /** + * {@inheritdoc} + */ public function __sleep() { $keys = parent::__sleep(); unset($keys[array_search('executable', $keys)]);