You are here

class MaintenanceModeSubscriber in uLogin (advanced version) 8

Maintenance Mode Subscriber.

Hierarchy

  • class \Drupal\ulogin\EventSubscriber\MaintenanceModeSubscriber implements \Symfony\Component\EventDispatcher\EventSubscriberInterface

Expanded class hierarchy of MaintenanceModeSubscriber

1 string reference to 'MaintenanceModeSubscriber'
ulogin.services.yml in ./ulogin.services.yml
ulogin.services.yml
1 service uses MaintenanceModeSubscriber
ulogin_maintenance_mode_subscriber in ./ulogin.services.yml
Drupal\ulogin\EventSubscriber\MaintenanceModeSubscriber

File

src/EventSubscriber/MaintenanceModeSubscriber.php, line 17
Contains \Drupal\ulogin\EventSubscriber\MaintenanceModeSubscriber.

Namespace

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

  /**
   * Does something.
   *
   * @param \Symfony\Component\HttpKernel\Event\GetResponseEvent $event
   *   The event to process.
   */
  public function onKernelRequestMaintenance(GetResponseEvent $event) {
    $request = $event
      ->getRequest();
    if ($request->attributes
      ->get('_maintenance') == 4 && \Drupal::currentUser()
      ->isAnonymous() && $request
      ->getPathInfo() == 'ulogin') {

      // Allow access to ulogin path even if site is in offline mode.
      $request->attributes
        ->set('_maintenance', 5);
    }
  }

  /**
   * {@inheritdoc}
   */
  public static function getSubscribedEvents() {
    $events[KernelEvents::REQUEST][] = [
      '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.
MaintenanceModeSubscriber::onKernelRequestMaintenance public function Does something.