Commit a93de787 authored by alexpott's avatar alexpott

Issue #1992606 by damiankloip, pwieck: Convert system_theme_settings() to FormInterface.

parent f36f4806
......@@ -1517,6 +1517,7 @@ function theme_enable($theme_list) {
$disabled_themes->save();
list_themes(TRUE);
Drupal::service('router.builder')->rebuild();
menu_router_rebuild();
drupal_theme_rebuild();
......@@ -1552,6 +1553,7 @@ function theme_disable($theme_list) {
$disabled_themes->save();
list_themes(TRUE);
Drupal::service('router.builder')->rebuild();
menu_router_rebuild();
drupal_theme_rebuild();
......
......@@ -57,10 +57,12 @@ public function content(Request $request, $_form) {
$request->attributes->set('form', array());
$request->attributes->set('form_state', $form_state);
$args = $this->container->get('controller_resolver')->getArguments($request, array($form_object, 'buildForm'));
unset($args[0], $args[1]);
$request->attributes->remove('form');
$request->attributes->remove('form_state');
$form_state['build_info']['args'] = $args;
// Remove $form and $form_state from the arguments, and re-index them.
unset($args[0], $args[1]);
$form_state['build_info']['args'] = array_values($args);
$form_id = _drupal_form_id($form_object, $form_state);
return drupal_build_form($form_id, $form_state);
......
......@@ -64,6 +64,7 @@ public function testBlockNotInHiddenRegion() {
config('system.theme')
->set('default', $theme)
->save();
\Drupal::service('router.builder')->rebuild();
menu_router_rebuild();
// Ensure that "block_test_theme" is set as the default theme.
......
......@@ -48,6 +48,8 @@ function setUp() {
),
);
theme_enable(array_keys($this->themes));
$this->container->get('router.builder')->rebuild();
menu_router_rebuild();
// Array filled with valid and not valid color values
$this->colorTests = array(
......
<?php
/**
* @file
* Contains \Drupal\system\EventSubscriber\RouteSubscriber.
*/
namespace Drupal\system\Routing;
use Drupal\Core\Routing\RouteBuildEvent;
use Drupal\Core\Routing\RoutingEvents;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Symfony\Component\Routing\Route;
/**
* Event subscriber for routes.
*/
class RouteSubscriber implements EventSubscriberInterface {
/**
* Implements EventSubscriberInterface::getSubscribedEvents().
*/
static function getSubscribedEvents() {
$events[RoutingEvents::DYNAMIC] = 'createSystemThemeRoutes';
return $events;
}
/**
* Adds dynamic system theme routes.
*
* @param \Drupal\Core\Routing\RouteBuildEvent $event
* The route building event.
*/
public function createSystemThemeRoutes(RouteBuildEvent $event) {
$collection = $event->getRouteCollection();
foreach (list_themes() as $theme) {
if (!empty($theme->status)) {
$route = new Route('admin/appearance/settings/' . $theme->name, array(
'_form' => '\Drupal\system\Form\ThemeSettingsForm', 'theme_name' => $theme->name), array(
'_permission' => 'administer themes',
));
$collection->add('system_theme_settings_' . $theme->name, $route);
}
}
}
}
......@@ -338,6 +338,7 @@ function testMenuName() {
// Change the menu_name parameter in menu_test.module, then force a menu
// rebuild.
menu_test_menu_name('changed');
\Drupal::service('router.builder')->rebuild();
menu_router_rebuild();
$menu_links = entity_load_multiple_by_properties('menu_link', array('router_path' => 'menu_name_test'));
......
......@@ -231,6 +231,8 @@ function testSwitchDefaultTheme() {
$this->clickLink(t('Set default'));
$this->assertEqual(config('system.theme')->get('default'), 'bartik');
drupal_flush_all_caches();
// Test the default theme on the secondary links (blocks admin page).
$this->drupalGet('admin/structure/block');
$this->assertText('Bartik(' . t('active tab') . ')', 'Default local task on blocks admin page is the default theme.');
......
This diff is collapsed.
......@@ -710,28 +710,24 @@ function system_menu() {
$items['admin/appearance/settings'] = array(
'title' => 'Settings',
'description' => 'Configure default and theme specific settings.',
'page callback' => 'drupal_get_form',
'page arguments' => array('system_theme_settings'),
'access arguments' => array('administer themes'),
'route_name' => 'system_theme_settings',
'type' => MENU_LOCAL_TASK,
'file' => 'system.admin.inc',
'weight' => 100,
);
// Theme configuration subtabs.
// Theme configuration local tasks.
$items['admin/appearance/settings/global'] = array(
'title' => 'Global settings',
'type' => MENU_DEFAULT_LOCAL_TASK,
);
foreach (list_themes() as $key => $theme) {
$items['admin/appearance/settings/' . $theme->name] = array(
'title' => $theme->info['name'],
'page arguments' => array('system_theme_settings', $theme->name),
'type' => MENU_LOCAL_TASK,
'access callback' => '_system_themes_access',
'access arguments' => array($key),
'file' => 'system.admin.inc',
);
foreach (list_themes(TRUE) as $theme) {
if (!empty($theme->status)) {
$items['admin/appearance/settings/' . $theme->name] = array(
'title' => $theme->info['name'],
'route_name' => 'system_theme_settings_' . $theme->name,
'type' => MENU_LOCAL_TASK,
);
}
}
// Modules.
......
......@@ -143,3 +143,17 @@ system_admin_index:
_content: 'Drupal\system\Controller\AdminController::index'
requirements:
_permission: 'access administration pages'
system_theme_settings:
pattern: '/admin/appearance/settings'
defaults:
_form: '\Drupal\system\Form\ThemeSettingsForm'
requirements:
_permission: 'administer themes'
system_theme_settings_global:
pattern: '/admin/appearance/settings/global'
defaults:
_form: '\Drupal\system\Form\ThemeSettingsForm'
requirements:
_permission: 'administer themes'
......@@ -13,3 +13,7 @@ services:
class: Drupal\system\LegacyBreadcrumbBuilder
tags:
- {name: breadcrumb_builder, priority: 500}
system.route_subscriber:
class: Drupal\system\Routing\RouteSubscriber
tags:
- { name: event_subscriber }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment