diff --git a/core/modules/system/lib/Drupal/system/Controller/ThemeController.php b/core/modules/system/lib/Drupal/system/Controller/ThemeController.php index 61461b8..e0b119c 100644 --- a/core/modules/system/lib/Drupal/system/Controller/ThemeController.php +++ b/core/modules/system/lib/Drupal/system/Controller/ThemeController.php @@ -9,12 +9,15 @@ use Drupal\Core\Config\Config; use Drupal\Core\Controller\ControllerBase; +use Drupal\Core\Controller\ControllerInterface; +use Symfony\Component\DependencyInjection\ContainerInterface; +use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException; /** * Controller for theme handling. */ -class ThemeController implements ControllerInterface { +class ThemeController extends ControllerBase implements ControllerInterface { /** * The system.theme config object. @@ -52,6 +55,9 @@ public static function create(ContainerInterface $container) { /** * Disables a theme. * + * @param \Symfony\Component\HttpFoundation\Request $request + * A request object containing a theme name and a valid token. + * * @return \Symfony\Component\HttpFoundation\RedirectResponse * Redirects back to the appearance admin page. * @@ -59,9 +65,9 @@ public static function create(ContainerInterface $container) { * Throws access denied when no theme or token is set in the request or when * the token is invalid. */ - public function disable() { - $theme = $this->request->get('theme'); - $token = $this->request->get('token'); + public function disable(Request $request) { + $theme = $request->get('theme'); + $token = $request->get('token'); if (isset($theme) && isset($token) && drupal_valid_token($token, 'system-theme-operation-link')) { // Get current list of themes. @@ -91,6 +97,9 @@ public function disable() { /** * Enables a theme. * + * @param \Symfony\Component\HttpFoundation\Request $request + * A request object containing a theme name and a valid token. + * * @return \Symfony\Component\HttpFoundation\RedirectResponse * Redirects back to the appearance admin page. * @@ -98,9 +107,9 @@ public function disable() { * Throws access denied when no theme or token is set in the request or when * the token is invalid. */ - public function enable() { - $theme = $this->request->get('theme'); - $token = $this->request->get('token'); + public function enable(Request $request) { + $theme = $request->get('theme'); + $token = $request->get('token'); if (isset($theme) && isset($token) && drupal_valid_token($token, 'system-theme-operation-link')) { // Get current list of themes. @@ -122,7 +131,10 @@ public function enable() { } /** - * Set the default theme. + * Sets the default theme. + * + * @param \Symfony\Component\HttpFoundation\Request $request + * A request object containing a theme name and a valid token. * * @return \Symfony\Component\HttpFoundation\RedirectResponse * Redirects back to the appearance admin page. @@ -131,12 +143,12 @@ public function enable() { * Throws access denied when no theme or token is set in the request or when * the token is invalid. */ - public function defaultTheme() { + public function defaultTheme(Request $request) { // Set the page title. drupal_set_title($this->t('Set default theme')); - $theme = $this->request->query->get('theme'); - $token = $this->request->query->get('token'); + $theme = $request->query->get('theme'); + $token = $request->query->get('token'); if (isset($theme) && isset($token) && drupal_valid_token($token, 'system-theme-operation-link')) { // Get current list of themes. $themes = list_themes(); diff --git a/core/modules/system/system.admin.inc b/core/modules/system/system.admin.inc index df7ef6f..e3acffb 100644 --- a/core/modules/system/system.admin.inc +++ b/core/modules/system/system.admin.inc @@ -198,57 +198,6 @@ function system_themes_admin_form_submit($form, &$form_state) { } /** - * Menu callback; Set the default theme. - */ -function system_theme_default() { - $request = Drupal::request(); - $theme = $request->get('theme'); - $token = $request->get('token'); - if (!empty($theme) && !empty($token) && drupal_valid_token($token, 'system-theme-operation-link')) { - // Get current list of themes. - $themes = list_themes(); - - // Check if the specified theme is one recognized by the system. - if (!empty($themes[$theme])) { - // Enable the theme if it is currently disabled. - if (empty($themes[$theme]->status)) { - theme_enable(array($theme)); - } - // Set the default theme. - Drupal::config('system.theme') - ->set('default', $theme) - ->save(); - - // Rebuild the menu. This duplicates the menu_router_rebuild() in - // theme_enable(). However, modules must know the current default theme in - // order to use this information in hook_menu() or hook_menu_alter() - // implementations, and doing the variable_set() before the theme_enable() - // could result in a race condition where the theme is default but not - // enabled. - menu_router_rebuild(); - - // The status message depends on whether an admin theme is currently in use: - // a value of 0 means the admin theme is set to be the default theme. - $admin_theme = Drupal::config('system.theme')->get('admin'); - if ($admin_theme != 0 && $admin_theme != $theme) { - drupal_set_message(t('Please note that the administration theme is still set to the %admin_theme theme; consequently, the theme on this page remains unchanged. All non-administrative sections of the site, however, will show the selected %selected_theme theme by default.', array( - '%admin_theme' => $themes[$admin_theme]->info['name'], - '%selected_theme' => $themes[$theme]->info['name'], - ))); - } - else { - drupal_set_message(t('%theme is now the default theme.', array('%theme' => $themes[$theme]->info['name']))); - } - } - else { - drupal_set_message(t('The %theme theme was not found.', array('%theme' => $theme)), 'error'); - } - return new RedirectResponse(url('admin/appearance', array('absolute' => TRUE))); - } - throw new AccessDeniedHttpException(); -} - -/** * Recursively check compatibility. * * @param $incompatible