diff --git a/core/includes/install.core.inc b/core/includes/install.core.inc index 4804590..e424ae4 100644 --- a/core/includes/install.core.inc +++ b/core/includes/install.core.inc @@ -369,7 +369,8 @@ function install_begin_request(&$install_state) { $container ->register('theme.registry', 'Drupal\Core\Theme\Registry') ->addArgument(new Reference('cache.cache')) - ->addArgument(new Reference('module_handler')); + ->addArgument(new Reference('module_handler')) + ->addTag('needs_destruction'); // Register a module handler for managing enabled modules. $container diff --git a/core/lib/Drupal/Core/CoreBundle.php b/core/lib/Drupal/Core/CoreBundle.php index fc8b3e2..5f6415e 100644 --- a/core/lib/Drupal/Core/CoreBundle.php +++ b/core/lib/Drupal/Core/CoreBundle.php @@ -195,7 +195,8 @@ public function build(ContainerBuilder $container) { $container ->register('theme.registry', 'Drupal\Core\Theme\Registry') ->addArgument(new Reference('cache.cache')) - ->addArgument(new Reference('module_handler')); + ->addArgument(new Reference('module_handler')) + ->addTag('needs_destruction'); $this->registerTwig($container); $this->registerRouting($container); diff --git a/core/lib/Drupal/Core/Theme/Registry.php b/core/lib/Drupal/Core/Theme/Registry.php index 5f01c58..53bd67a 100644 --- a/core/lib/Drupal/Core/Theme/Registry.php +++ b/core/lib/Drupal/Core/Theme/Registry.php @@ -9,6 +9,7 @@ use Drupal\Component\Utility\NestedArray; use Drupal\Core\Cache\CacheBackendInterface; +use Drupal\Core\DestructableInterface; use Drupal\Core\Extension\ModuleHandlerInterface; use Drupal\Core\Utility\ThemeRegistry; @@ -17,7 +18,7 @@ * * @todo Replace local $registry variables in methods with $this->registry. */ -class Registry { +class Registry implements DestructableInterface { /** * The theme object representing the active theme for this registry. @@ -685,4 +686,13 @@ public function reset() { return $this; } + /** + * Implements Drupal\Core\DestructableInterface::destruct(). + */ + public function destruct() { + if (isset($this->runtimeRegistry)) { + $this->runtimeRegistry->destruct(); + } + } + } diff --git a/core/lib/Drupal/Core/Utility/ThemeRegistry.php b/core/lib/Drupal/Core/Utility/ThemeRegistry.php index d88d294..550e297 100644 --- a/core/lib/Drupal/Core/Utility/ThemeRegistry.php +++ b/core/lib/Drupal/Core/Utility/ThemeRegistry.php @@ -8,6 +8,7 @@ namespace Drupal\Core\Utility; use Drupal\Core\Cache\CacheBackendInterface; +use Drupal\Core\DestructableInterface; /** * Builds the run-time theme registry. @@ -17,7 +18,7 @@ * that are actually in use on the site. On cache misses the complete * theme registry is loaded and used to update the run-time cache. */ -class ThemeRegistry extends CacheArray { +class ThemeRegistry extends CacheArray implements DestructableInterface { /** * Whether the partial registry can be persisted to the cache. @@ -144,4 +145,19 @@ public function set($data, $lock = TRUE) { } } } + + + /** + * Implements Drupal\Core\DestructableInterface::destruct(). + */ + public function destruct() { + parent::__destruct(); + } + + /** + * Destructs the ThemeRegistry object. + */ + public function __destruct() { + } + } diff --git a/core/modules/views/lib/Drupal/views/Plugin/views/display/DisplayPluginBase.php b/core/modules/views/lib/Drupal/views/Plugin/views/display/DisplayPluginBase.php index 4040520..286c19f 100644 --- a/core/modules/views/lib/Drupal/views/Plugin/views/display/DisplayPluginBase.php +++ b/core/modules/views/lib/Drupal/views/Plugin/views/display/DisplayPluginBase.php @@ -1718,7 +1718,7 @@ public function buildOptionsForm(&$form, &$form_state) { } if (isset($GLOBALS['theme']) && $GLOBALS['theme'] == $this->theme) { - $this->theme_registry = drupal_container()->get('theme.registry')->get(); + $this->theme_registry = \Drupal::service('theme.registry')->get(); $theme_engine = $GLOBALS['theme_engine']; } else {