diff --git a/core/core.services.yml b/core/core.services.yml index 49c8059..c6e92b9 100644 --- a/core/core.services.yml +++ b/core/core.services.yml @@ -152,12 +152,9 @@ services: calls: - [addSubscriber, ['@http_client_simpletest_subscriber']] - [setUserAgent, ['Drupal (+http://drupal.org/)']] - theme.active: - class: Drupal\Core\Theme\ActiveTheme - arguments: ['@request', '@plugin.manager.entity', '@config.factory'] theme.negotiator: class: Drupal\Core\Theme\ThemeNegotiator - arguments: ['@request', '@theme.active'] + arguments: ['@request'] theme.negotiator.default: class: Drupal\Core\Theme\DefaultNegotiator arguments: ['@config.factory'] diff --git a/core/includes/theme.inc b/core/includes/theme.inc index 7221839..9910eb2 100644 --- a/core/includes/theme.inc +++ b/core/includes/theme.inc @@ -94,11 +94,11 @@ function drupal_theme_initialize() { drupal_bootstrap(DRUPAL_BOOTSTRAP_DATABASE); // Only select the user selected theme if it is available in the // list of themes that can be accessed. - $active_theme = Drupal::service('theme.active'); - $themes = $active_theme->getAll(); + $themes = list_themes(); // @todo Let the theme.negotiator listen to the kernel request event. - Drupal::service('theme.negotiator')->determineActiveTheme(Drupal::request(), $active_theme); + $request = Drupal::request(); + Drupal::service('theme.negotiator')->determineActiveTheme($request); // @todo Convert to a theme negotiator. // service. @@ -106,10 +106,10 @@ function drupal_theme_initialize() { // inside menu_get_custom_theme(), so we do not need to check it again here. $custom_theme = menu_get_custom_theme(); if ($custom_theme) { - $active_theme->set($custom_theme); + $request->attributes->set('_theme_active', $custom_theme); } - $theme = $active_theme->get(); + $theme = $request->attributes->get('theme_active'); // Store the identifier for retrieving theme settings with. $theme_key = $theme; diff --git a/core/lib/Drupal/Core/Theme/DefaultNegotiator.php b/core/lib/Drupal/Core/Theme/DefaultNegotiator.php index d28b1a9..f155b0d 100644 --- a/core/lib/Drupal/Core/Theme/DefaultNegotiator.php +++ b/core/lib/Drupal/Core/Theme/DefaultNegotiator.php @@ -28,8 +28,8 @@ public function __construct(ConfigFactory $config_factory) { /** * {@inheritdoc} */ - public function determineActiveTheme(Request $request, ActiveTheme $active_theme) { - $active_theme->set($this->config->get('default')); + public function determineActiveTheme(Request $request) { + return $this->config->get('default'); } } diff --git a/core/lib/Drupal/Core/Theme/ThemeNegotiator.php b/core/lib/Drupal/Core/Theme/ThemeNegotiator.php index 7571cb7..392b385 100644 --- a/core/lib/Drupal/Core/Theme/ThemeNegotiator.php +++ b/core/lib/Drupal/Core/Theme/ThemeNegotiator.php @@ -39,11 +39,10 @@ class ThemeNegotiator implements ThemeNegotiatorInterface { * @param \Drupal\Core\Theme\ActiveTheme $active_theme * The active theme service. */ - public function __construct(Request $request, ActiveTheme $active_theme) { + public function __construct(Request $request) { $this->request = $request; - $this->activeTheme = $active_theme; - $this->determineActiveTheme($request, $active_theme); + $this->determineActiveTheme($request); } /** @@ -83,9 +82,11 @@ protected function getSortedNegotiators() { /** * {@inheritdoc} */ - public function determineActiveTheme(Request $request, ActiveTheme $theme_active) { + public function determineActiveTheme(Request $request) { foreach ($this->getSortedNegotiators() as $negotiator) { - $negotiator->determineActiveTheme($request, $theme_active); + if (($active_theme = $negotiator->determineActiveTheme($request)) && $active_theme !== NULL) { + $request->attributes->set('_theme_active', $active_theme); + } } } diff --git a/core/lib/Drupal/Core/Theme/ThemeNegotiatorInterface.php b/core/lib/Drupal/Core/Theme/ThemeNegotiatorInterface.php index 4a9b6d5..9bb80b1 100644 --- a/core/lib/Drupal/Core/Theme/ThemeNegotiatorInterface.php +++ b/core/lib/Drupal/Core/Theme/ThemeNegotiatorInterface.php @@ -19,9 +19,10 @@ * * @param \Symfony\Component\HttpFoundation\Request $request * The active request of the site. - * @param \Drupal\Core\Theme\ActiveTheme $active_theme - * The active theme service. + * + * @return string|null + * Returns the active theme name, else return NULL. */ - public function determineActiveTheme(Request $request, ActiveTheme $active_theme); + public function determineActiveTheme(Request $request); } diff --git a/core/modules/user/lib/Drupal/user/Theme/UserNegotiator.php b/core/modules/user/lib/Drupal/user/Theme/UserNegotiator.php index b12767e..185703b 100644 --- a/core/modules/user/lib/Drupal/user/Theme/UserNegotiator.php +++ b/core/modules/user/lib/Drupal/user/Theme/UserNegotiator.php @@ -37,13 +37,13 @@ public function __construct(EntityManager $entity_manager) { /** * {@inheritdoc} */ - public function determineActiveTheme(Request $request, ActiveTheme $active_theme) { + public function determineActiveTheme(Request $request) { if ($account = $request->attributes->get('account')) {; if ($user = $this->userStorageController->load($account->id())) {; // Only select the user selected theme if it is available in the // list of themes that can be accessed. if (!empty($user->theme) && drupal_theme_access($user->theme)) { - $active_theme->set($user->theme); + return $user->theme; } } }