class MaintenanceModeSubscriber

Same name in this branch

Maintenance mode subscriber to set site online on a test.

Hierarchy

Expanded class hierarchy of MaintenanceModeSubscriber

1 string reference to 'MaintenanceModeSubscriber'
menu_test.services.yml in drupal/core/modules/system/tests/modules/menu_test/menu_test.services.yml
drupal/core/modules/system/tests/modules/menu_test/menu_test.services.yml
1 service uses MaintenanceModeSubscriber

File

drupal/core/modules/system/tests/modules/menu_test/lib/Drupal/menu_test/EventSubscriber/MaintenanceModeSubscriber.php, line 17
Contains \Drupal\menu_test\EventSubscriber\MaintenanceModeSubscriber.

Namespace

Drupal\menu_test\EventSubscriber
View source
class MaintenanceModeSubscriber implements EventSubscriberInterface {

  /**
   * Set the page online if called from a certain path.
   *
   * @param \Symfony\Component\HttpKernel\Event\GetResponseEvent $event
   *   The event to process.
   */
  public function onKernelRequestMaintenance(GetResponseEvent $event) {
    $request = $event
      ->getRequest();

    // Allow access to menu_login_callback even if in maintenance mode.
    if ($request->attributes
      ->get('_maintenance') == MENU_SITE_OFFLINE && $request->attributes
      ->get('system_path') == 'menu_login_callback') {
      $request->attributes
        ->set('_maintenance', MENU_SITE_ONLINE);
    }
  }

  /**
   * {@inheritdoc}
   */
  public static function getSubscribedEvents() {
    $events[KernelEvents::REQUEST][] = array(
      'onKernelRequestMaintenance',
      35,
    );
    return $events;
  }

}

Members

Namesort descending Modifiers Type Description Overrides
MaintenanceModeSubscriber::getSubscribedEvents public static function Returns an array of event names this subscriber wants to listen to. Overrides EventSubscriberInterface::getSubscribedEvents
MaintenanceModeSubscriber::onKernelRequestMaintenance public function Set the page online if called from a certain path.