db backup prior to drupal security update
[yaffs-website] / vendor / symfony / http-kernel / EventListener / AddRequestFormatsListener.php
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\KernelEvents;
16 use Symfony\Component\HttpKernel\Event\GetResponseEvent;
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     /**
26      * @var array
27      */
28     protected $formats;
29
30     /**
31      * @param array $formats
32      */
33     public function __construct(array $formats)
34     {
35         $this->formats = $formats;
36     }
37
38     /**
39      * Adds request formats.
40      *
41      * @param GetResponseEvent $event
42      */
43     public function onKernelRequest(GetResponseEvent $event)
44     {
45         foreach ($this->formats as $format => $mimeTypes) {
46             $event->getRequest()->setFormat($format, $mimeTypes);
47         }
48     }
49
50     /**
51      * {@inheritdoc}
52      */
53     public static function getSubscribedEvents()
54     {
55         return array(KernelEvents::REQUEST => array('onKernelRequest', 1));
56     }
57 }