class LegacyAccessSubscriber

Access subscriber for legacy controller requests.

Hierarchy

Expanded class hierarchy of LegacyAccessSubscriber

1 string reference to 'LegacyAccessSubscriber'
core.services.yml in drupal/core/core.services.yml
drupal/core/core.services.yml

File

drupal/core/lib/Drupal/Core/EventSubscriber/LegacyAccessSubscriber.php, line 18
Contains Drupal\Core\EventSubscriber\LegacyAccessSubscriber.

Namespace

Drupal\Core\EventSubscriber
View source
class LegacyAccessSubscriber implements EventSubscriberInterface {

  /**
   * Verifies that the current user can access the requested path.
   *
   * @todo This is a total hack to keep our current access system working. It
   *   should be replaced with something robust and injected at some point.
   *
   * @param Symfony\Component\HttpKernel\Event\GetResponseEvent $event
   *   The Event to process.
   */
  public function onKernelRequestAccessCheck(GetResponseEvent $event) {
    $router_item = $event
      ->getRequest()->attributes
      ->get('drupal_menu_item');
    if (isset($router_item['access']) && !$router_item['access']) {
      throw new AccessDeniedHttpException();
    }
  }

  /**
   * Registers the methods in this class that should be listeners.
   *
   * @return array
   *   An array of event listener definitions.
   */
  static function getSubscribedEvents() {
    $events[KernelEvents::REQUEST][] = array(
      'onKernelRequestAccessCheck',
      30,
    );
    return $events;
  }

}

Members

Namesort descending Modifiers Type Description Overrides
LegacyAccessSubscriber::getSubscribedEvents static function Registers the methods in this class that should be listeners. Overrides EventSubscriberInterface::getSubscribedEvents
LegacyAccessSubscriber::onKernelRequestAccessCheck public function Verifies that the current user can access the requested path.