class AjaxSubscriber

Subscribes to the kernel request event to add the Ajax media type.

Hierarchy

Expanded class hierarchy of AjaxSubscriber

1 string reference to 'AjaxSubscriber'
core.services.yml in drupal/core/core.services.yml
drupal/core/core.services.yml
1 service uses AjaxSubscriber

File

drupal/core/lib/Drupal/Core/Ajax/AjaxSubscriber.php, line 20
Contains \Drupal\Core\Ajax\AjaxSubscriber.

Namespace

Drupal\Core\Ajax
View source
class AjaxSubscriber implements EventSubscriberInterface {

  /**
   * Registers Ajax formats with the Request class.
   */
  public function onKernelRequest(GetResponseEvent $event) {
    $request = $event
      ->getRequest();
    $request
      ->setFormat('drupal_ajax', 'application/vnd.drupal-ajax');
    $request
      ->setFormat('drupal_dialog', 'application/vnd.drupal-dialog');
    $request
      ->setFormat('drupal_modal', 'application/vnd.drupal-modal');
  }

  /**
   * 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(
      'onKernelRequest',
      50,
    );
    return $events;
  }

}

Members

Namesort descending Modifiers Type Description Overrides
AjaxSubscriber::getSubscribedEvents static function Registers the methods in this class that should be listeners. Overrides EventSubscriberInterface::getSubscribedEvents
AjaxSubscriber::onKernelRequest public function Registers Ajax formats with the Request class.