You are here

class AddRequestFormatsListener in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 vendor/symfony/http-kernel/EventListener/AddRequestFormatsListener.php \Symfony\Component\HttpKernel\EventListener\AddRequestFormatsListener

Adds configured formats to each request.

@author Gildas Quemener <gildas.quemener@gmail.com>

Hierarchy

Expanded class hierarchy of AddRequestFormatsListener

1 file declares its use of AddRequestFormatsListener
AddRequestFormatsListenerTest.php in vendor/symfony/http-kernel/Tests/EventListener/AddRequestFormatsListenerTest.php

File

vendor/symfony/http-kernel/EventListener/AddRequestFormatsListener.php, line 23

Namespace

Symfony\Component\HttpKernel\EventListener
View source
class AddRequestFormatsListener implements EventSubscriberInterface {

  /**
   * @var array
   */
  protected $formats;

  /**
   * @param array $formats
   */
  public function __construct(array $formats) {
    $this->formats = $formats;
  }

  /**
   * Adds request formats.
   *
   * @param GetResponseEvent $event
   */
  public function onKernelRequest(GetResponseEvent $event) {
    foreach ($this->formats as $format => $mimeTypes) {
      $event
        ->getRequest()
        ->setFormat($format, $mimeTypes);
    }
  }

  /**
   * {@inheritdoc}
   */
  public static function getSubscribedEvents() {
    return array(
      KernelEvents::REQUEST => 'onKernelRequest',
    );
  }

}

Members

Namesort descending Modifiers Type Description Overrides
AddRequestFormatsListener::$formats protected property
AddRequestFormatsListener::getSubscribedEvents public static function Returns an array of event names this subscriber wants to listen to. Overrides EventSubscriberInterface::getSubscribedEvents
AddRequestFormatsListener::onKernelRequest public function Adds request formats.
AddRequestFormatsListener::__construct public function