diff --git a/core/modules/system/lib/Drupal/system/Controller/AdminPageController.php b/core/modules/system/lib/Drupal/system/Controller/AdminPageController.php
new file mode 100644
index 0000000..9da8ecd
--- /dev/null
+++ b/core/modules/system/lib/Drupal/system/Controller/AdminPageController.php
@@ -0,0 +1,28 @@
+<?php
+
+/**
+ * @file
+ * Contains \Drupal\system\Controller\AdminPageController.
+ */
+
+namespace Drupal\system\Controller;
+
+use Symfony\Component\HttpFoundation\Request;
+use Symfony\Component\DependencyInjection\ContainerInterface;
+
+/**
+ * Controller routines for machine name transliteration routes.
+ */
+class AdminPageController {
+
+  /**
+   * Sets whether the admin menu is in compact mode or not.
+   *
+   * @param $mode
+   *   Valid values are 'on' and 'off'.
+   */
+  function compactPage($mode = 'off') {
+    user_cookie_save(array('admin_compact_mode' => ($mode == 'on')));
+    drupal_goto();
+  }
+}
diff --git a/core/modules/system/system.module b/core/modules/system/system.module
index aaedc09..58f3b17 100644
--- a/core/modules/system/system.module
+++ b/core/modules/system/system.module
@@ -656,11 +656,8 @@ function system_menu() {
     'file' => 'system.admin.inc',
   );
   $items['admin/compact'] = array(
-    'title' => 'Compact mode',
-    'page callback' => 'system_admin_compact_page',
-    'access arguments' => array('access administration pages'),
+    'route_name' => 'system.admin_compact_page',
     'type' => MENU_CALLBACK,
-    'file' => 'system.admin.inc',
   );
   $items['admin/tasks'] = array(
     'title' => 'Tasks',
@@ -3499,14 +3496,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 AdminPageController->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() {
@@ -3516,17 +3513,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')));
-  drupal_goto();
-}
-
-/**
  * 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 69a3eae..8713ea4 100644
--- a/core/modules/system/system.routing.yml
+++ b/core/modules/system/system.routing.yml
@@ -10,3 +10,10 @@ system.machine_name_transliterate:
     _controller: '\Drupal\system\MachineNameController::transliterate'
   requirements:
     _permission: 'access content'
+
+system.admin_compact_page:
+  pattern: 'admin/compact'
+  defaults:
+    _controller: 'Drupal\system\AdminPageController::compactPage'
+  requirements:
+    _permission: 'access administration pages'
