Commit f325f63c authored by alexpott's avatar alexpott

Issue #1987808 by h3rj4n, vijaycs85, Dave.Ingram, tim.plunkett: Convert...

Issue #1987808 by h3rj4n, vijaycs85, Dave.Ingram, tim.plunkett: Convert system_admin_compact_page() to a new style controller.
parent 0dff05da
<?php
/**
* @file
* Contains \Drupal\system\Controller\SystemController.
*/
namespace Drupal\system\Controller;
use Drupal\Core\Controller\ControllerInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Symfony\Component\HttpFoundation\RedirectResponse;
/**
* Returns responses for System routes.
*/
class SystemController implements ControllerInterface {
/**
* {@inheritdoc}
*/
public static function create(ContainerInterface $container) {
return new static();
}
/**
* 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
*/
function compactPage($mode) {
user_cookie_save(array('admin_compact_mode' => ($mode == 'on')));
return new RedirectResponse(url('<front>', array('absolute' => TRUE)));
}
}
...@@ -627,13 +627,6 @@ function system_menu() { ...@@ -627,13 +627,6 @@ function system_menu() {
'menu_name' => 'admin', 'menu_name' => 'admin',
'file' => 'system.admin.inc', '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( $items['admin/tasks'] = array(
'title' => 'Tasks', 'title' => 'Tasks',
'type' => MENU_DEFAULT_LOCAL_TASK, 'type' => MENU_DEFAULT_LOCAL_TASK,
...@@ -2947,14 +2940,14 @@ function confirm_form($form, $question, $path, $description = NULL, $yes = NULL, ...@@ -2947,14 +2940,14 @@ function confirm_form($form, $question, $path, $description = NULL, $yes = NULL,
* such as the configuration page and the permissions page. * such as the configuration page and the permissions page.
* *
* Whether the user is in compact mode is determined by a cookie, which is set * 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 * 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 * 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 * does not have a user interface to set it: it is a hidden variable which can
* be set in the settings.php file. * be set in the settings.php file.
* *
* @return * @return bool
* TRUE when in compact mode, FALSE when in expanded mode. * TRUE when in compact mode, FALSE when in expanded mode.
*/ */
function system_admin_compact_mode() { function system_admin_compact_mode() {
...@@ -2963,17 +2956,6 @@ function system_admin_compact_mode() { ...@@ -2963,17 +2956,6 @@ function system_admin_compact_mode() {
return isset($_COOKIE['Drupal_visitor_admin_compact_mode']) ? $_COOKIE['Drupal_visitor_admin_compact_mode'] : Drupal::config('system.site')->get('admin_compact_mode'); return isset($_COOKIE['Drupal_visitor_admin_compact_mode']) ? $_COOKIE['Drupal_visitor_admin_compact_mode'] : Drupal::config('system.site')->get('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('<front>', array('absolute' => TRUE)));
}
/** /**
* Generate a list of tasks offered by a specified module. * Generate a list of tasks offered by a specified module.
* *
......
...@@ -10,6 +10,15 @@ system.cron: ...@@ -10,6 +10,15 @@ system.cron:
_controller: '\Drupal\system\CronController::run' _controller: '\Drupal\system\CronController::run'
requirements: requirements:
_access_system_cron: 'TRUE' _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: system.machine_name_transliterate:
pattern: '/machine_name/transliterate' pattern: '/machine_name/transliterate'
defaults: defaults:
......
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