function SystemController::compactPage

Same name and namespace in other branches
  1. 11.x core/modules/system/src/Controller/SystemController.php \Drupal\system\Controller\SystemController::compactPage()
  2. 10 core/modules/system/src/Controller/SystemController.php \Drupal\system\Controller\SystemController::compactPage()
  3. 9 core/modules/system/src/Controller/SystemController.php \Drupal\system\Controller\SystemController::compactPage()
  4. 8.9.x core/modules/system/src/Controller/SystemController.php \Drupal\system\Controller\SystemController::compactPage()

Sets whether the admin menu is in compact mode or not.

Attributes

#[Route(path: '/admin/compact/{mode}', name: 'system.admin_compact_page', requirements: [ '_permission' => 'access administration pages', ], defaults: [ 'mode' => 'off', ])]

Parameters

string $mode: Valid values are 'on' and 'off'.

Return value

\Symfony\Component\HttpFoundation\RedirectResponse A redirect response to the front page.

File

core/modules/system/src/Controller/SystemController.php, line 131

Class

SystemController
Returns responses for System routes.

Namespace

Drupal\system\Controller

Code

public function compactPage($mode) {
  $response = $this->redirect('<front>');
  if ($mode === 'on') {
    $response->headers
      ->setCookie(new Cookie('Drupal.visitor.admin_compact_mode', '1', $this->time
      ->getRequestTime() + 31536000));
  }
  else {
    $response->headers
      ->clearCookie('Drupal.visitor.admin_compact_mode');
  }
  return $response;
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.