diff --git a/core/modules/system/lib/Drupal/system/Controller/SystemController.php b/core/modules/system/lib/Drupal/system/Controller/SystemController.php index bd71353..c28fe22 100644 --- a/core/modules/system/lib/Drupal/system/Controller/SystemController.php +++ b/core/modules/system/lib/Drupal/system/Controller/SystemController.php @@ -7,17 +7,68 @@ namespace Drupal\system\Controller; +use Drupal\Component\Plugin\PluginManagerInterface; use Drupal\Component\Utility\Tags; use Drupal\Component\Utility\Unicode; -use Symfony\Component\DependencyInjection\ContainerAware; +use Drupal\Core\Controller\ControllerInterface; +use Drupal\Core\Routing\PathBasedGeneratorInterface; +use Symfony\Component\DependencyInjection\ContainerInterface; use Symfony\Component\HttpFoundation\JsonResponse; +use Symfony\Component\HttpFoundation\RedirectResponse; use Symfony\Component\HttpFoundation\Request; - /** * Returns responses for System routes. */ -class SystemController extends ContainerAware { +class SystemController implements ControllerInterface { + + /** + * The plugin UI manager. + * + * @var \Drupal\Component\Plugin\PluginManagerInterface + */ + protected $pluginUiManager; + + /** + * The URL generator. + * + * @var \Drupal\Core\Routing\PathBasedGeneratorInterface + */ + protected $urlGenerator; + + /** + * The dependency injection container. + * + * @var \Symfony\Component\DependencyInjection\ContainerInterface + */ + protected $container; + + /** + * Constructs a new SystemController object. + * + * @param \Symfony\Component\DependencyInjection\ContainerInterface $container + * The dependency injection container. + * @param \Drupal\Component\Plugin\PluginManagerInterface $plugin_ui_manager + * The plugin UI manager. + * @param \Drupal\Core\Routing\PathBasedGeneratorInterface $url_generator + * The URL generator. + */ + public function __construct(ContainerInterface $container, PluginManagerInterface $plugin_ui_manager, PathBasedGeneratorInterface $url_generator) { + $this->container = $container; + $this->pluginUiManager = $plugin_ui_manager; + $this->urlGenerator = $url_generator; + } + + /** + * {@inheritdoc} + */ + public static function create(ContainerInterface $container) { + return new static( + $container, + $container->get('plugin.manager.system.plugin_ui'), + $container->get('url_generator') + ); + } /** * Autocompletes any plugin system tied to a plugin UI plugin. @@ -41,7 +92,7 @@ public function autocomplete($plugin_id, Request $request) { $string = Unicode::strtolower(array_pop($string_typed)); $matches = array(); if ($string) { - $plugin_ui = $this->container->get('plugin.manager.system.plugin_ui')->getDefinition($plugin_id); + $plugin_ui = $this->pluginUiManager->getDefinition($plugin_id); $manager = $this->container->get($plugin_ui['manager']); $titles = array(); foreach($manager->getDefinitions() as $plugin_id => $plugin) { @@ -53,4 +104,17 @@ public function autocomplete($plugin_id, Request $request) { return new JsonResponse($matches); } + /** + * Sets whether the admin menu is in compact mode or not. + * + * @param string $mode + * Valid values are 'on' and 'off'. + * + * @return \Symfony\Component\HttpFoundation\RedirectResponse + */ + public function compactPage($mode) { + user_cookie_save(array('admin_compact_mode' => ($mode == 'on'))); + return new RedirectResponse(url('', array('absolute' => TRUE))); + } + } diff --git a/core/modules/system/system.module b/core/modules/system/system.module index fc7bb6d..2f8963f 100644 --- a/core/modules/system/system.module +++ b/core/modules/system/system.module @@ -631,13 +631,6 @@ function system_menu() { 'menu_name' => 'admin', 'file' => 'system.admin.inc', ); - $items['admin/compact'] = array( - 'title' => 'Compact mode', - 'page callback' => 'system_admin_compact_page', - 'access arguments' => array('access administration pages'), - 'type' => MENU_CALLBACK, - 'file' => 'system.admin.inc', - ); $items['admin/tasks'] = array( 'title' => 'Tasks', 'type' => MENU_DEFAULT_LOCAL_TASK, @@ -3069,14 +3062,14 @@ function confirm_form($form, $question, $path, $description = NULL, $yes = NULL, * such as the configuration page and the permissions page. * * Whether the user is in compact mode is determined by a cookie, which is set - * for the user by system_admin_compact_page(). + * for the user by \Drupal\system\Controller\SystemController::compactPage(). * * If the user does not have the cookie, the default value is given by the * system variable 'admin_compact_mode', which itself defaults to FALSE. This * does not have a user interface to set it: it is a hidden variable which can * be set in the settings.php file. * - * @return + * @return bool * TRUE when in compact mode, FALSE when in expanded mode. */ function system_admin_compact_mode() { @@ -3086,17 +3079,6 @@ function system_admin_compact_mode() { } /** - * Menu callback; Sets whether the admin menu is in compact mode or not. - * - * @param $mode - * Valid values are 'on' and 'off'. - */ -function system_admin_compact_page($mode = 'off') { - user_cookie_save(array('admin_compact_mode' => ($mode == 'on'))); - return new RedirectResponse(url('', array('absolute' => TRUE))); -} - -/** * Generate a list of tasks offered by a specified module. * * @param $module diff --git a/core/modules/system/system.routing.yml b/core/modules/system/system.routing.yml index 61363d6..2355849 100644 --- a/core/modules/system/system.routing.yml +++ b/core/modules/system/system.routing.yml @@ -10,6 +10,15 @@ system.cron: _controller: '\Drupal\system\CronController::run' requirements: _access_system_cron: 'TRUE' + +system_admin_compact_page: + pattern: '/admin/compact/{mode}' + defaults: + _controller: 'Drupal\system\Controller\SystemController::compactPage' + mode: 'off' + requirements: + _permission: 'access administration pages' + system.machine_name_transliterate: pattern: '/machine_name/transliterate' defaults: