[ Index ]

PHP Cross Reference of phpBB-3.2.11-deutsch

title

Body

[close]

/vendor/symfony/http-kernel/EventListener/ -> AddRequestFormatsListener.php (source)

   1  <?php
   2  
   3  /*
   4   * This file is part of the Symfony package.
   5   *
   6   * (c) Fabien Potencier <fabien@symfony.com>
   7   *
   8   * For the full copyright and license information, please view the LICENSE
   9   * file that was distributed with this source code.
  10   */
  11  
  12  namespace Symfony\Component\HttpKernel\EventListener;
  13  
  14  use Symfony\Component\EventDispatcher\EventSubscriberInterface;
  15  use Symfony\Component\HttpKernel\Event\GetResponseEvent;
  16  use Symfony\Component\HttpKernel\KernelEvents;
  17  
  18  /**
  19   * Adds configured formats to each request.
  20   *
  21   * @author Gildas Quemener <gildas.quemener@gmail.com>
  22   */
  23  class AddRequestFormatsListener implements EventSubscriberInterface
  24  {
  25      protected $formats;
  26  
  27      public function __construct(array $formats)
  28      {
  29          $this->formats = $formats;
  30      }
  31  
  32      /**
  33       * Adds request formats.
  34       */
  35      public function onKernelRequest(GetResponseEvent $event)
  36      {
  37          $request = $event->getRequest();
  38          foreach ($this->formats as $format => $mimeTypes) {
  39              $request->setFormat($format, $mimeTypes);
  40          }
  41      }
  42  
  43      /**
  44       * {@inheritdoc}
  45       */
  46      public static function getSubscribedEvents()
  47      {
  48          return array(KernelEvents::REQUEST => array('onKernelRequest', 1));
  49      }
  50  }


Generated: Wed Nov 11 20:33:01 2020 Cross-referenced by PHPXref 0.7.1