function hook_menu_site_status_alter

Control site status before menu dispatching.

The hook is called after checking whether the site is offline but before the current router item is retrieved and executed. If the site is in offline mode, $menu_site_status is set to MENU_SITE_OFFLINE.

Parameters

$menu_site_status: Supported values are MENU_SITE_OFFLINE, MENU_ACCESS_DENIED, MENU_NOT_FOUND and MENU_SITE_ONLINE. Any other value than MENU_SITE_ONLINE will skip the default menu handling system and be passed for delivery directly.

$path: Contains the system path that is going to be loaded. This is read only, use hook_url_inbound_alter() to change the path.

Related topics

4 functions implement hook_menu_site_status_alter()

Note: this list is generated by pattern matching, so it may include some functions that are not actually implementations of this hook.

menu_test_menu_site_status_alter in drupal/core/modules/system/tests/modules/menu_test/menu_test.module
Implements hook_menu_site_status_alter().
openid_menu_site_status_alter in drupal/core/modules/openid/openid.module
Implements hook_menu_site_status_alter().
openid_test_menu_site_status_alter in drupal/core/modules/openid/tests/openid_test.module
Implements hook_menu_site_status_alter().
user_menu_site_status_alter in drupal/core/modules/user/user.module
Implements hook_menu_site_status_alter().
1 invocation of hook_menu_site_status_alter()
MaintenanceModeSubscriber::onKernelRequestMaintenanceModeCheck in drupal/core/lib/Drupal/Core/EventSubscriber/MaintenanceModeSubscriber.php
Response with the maintenance page when the site is offline.

File

drupal/core/modules/system/system.api.php, line 3742
Hooks provided by Drupal core and the System module.

Code

function hook_menu_site_status_alter(&$menu_site_status, $path) {

  // Allow access to my_module/authentication even if site is in offline mode.
  if ($menu_site_status == MENU_SITE_OFFLINE && user_is_anonymous() && $path == 'my_module/authentication') {
    $menu_site_status = MENU_SITE_ONLINE;
  }
}