diff --git a/core/lib/Drupal/Component/Plugin/PluginBag.php b/core/lib/Drupal/Component/Plugin/PluginBag.php index 18b09d0..656c8ce 100644 --- a/core/lib/Drupal/Component/Plugin/PluginBag.php +++ b/core/lib/Drupal/Component/Plugin/PluginBag.php @@ -35,6 +35,13 @@ abstract protected function initializePlugin($instance_id); /** + * Clears all instantiated plugins. + */ + public function clear() { + $this->pluginInstances = array(); + } + + /** * Implements \ArrayAccess::offsetExists(). */ public function offsetExists($offset) { diff --git a/core/modules/views/lib/Drupal/views/DisplayArray.php b/core/modules/views/lib/Drupal/views/DisplayArray.php index eb5b23b..ad6daec 100644 --- a/core/modules/views/lib/Drupal/views/DisplayArray.php +++ b/core/modules/views/lib/Drupal/views/DisplayArray.php @@ -41,10 +41,18 @@ public function __construct(ViewExecutable $view) { * Destructs a DisplayArray object. */ public function __destruct() { + $this->clear(); + } + + /** + * Overrides \Drupal\Component\Plugin\PluginBag::clear(). + */ + public function clear() { foreach ($this->pluginInstances as $display_id => $display) { $display->destroy(); - unset($this->pluginInstances[$display_id]); } + + parent::clear(); } /**