equal
deleted
inserted
replaced
|
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\Bridge\Monolog\Handler; |
|
13 |
|
14 use Monolog\Handler\FirePHPHandler as BaseFirePHPHandler; |
|
15 use Symfony\Component\HttpKernel\Event\FilterResponseEvent; |
|
16 use Symfony\Component\HttpFoundation\Response; |
|
17 use Symfony\Component\HttpKernel\HttpKernelInterface; |
|
18 |
|
19 /** |
|
20 * FirePHPHandler. |
|
21 * |
|
22 * @author Jordi Boggiano <j.boggiano@seld.be> |
|
23 */ |
|
24 class FirePHPHandler extends BaseFirePHPHandler |
|
25 { |
|
26 /** |
|
27 * @var array |
|
28 */ |
|
29 private $headers = array(); |
|
30 |
|
31 /** |
|
32 * @var Response |
|
33 */ |
|
34 private $response; |
|
35 |
|
36 /** |
|
37 * Adds the headers to the response once it's created |
|
38 */ |
|
39 public function onKernelResponse(FilterResponseEvent $event) |
|
40 { |
|
41 if (HttpKernelInterface::MASTER_REQUEST !== $event->getRequestType()) { |
|
42 return; |
|
43 } |
|
44 |
|
45 $this->response = $event->getResponse(); |
|
46 foreach ($this->headers as $header => $content) { |
|
47 $this->response->headers->set($header, $content); |
|
48 } |
|
49 $this->headers = array(); |
|
50 } |
|
51 |
|
52 /** |
|
53 * {@inheritDoc} |
|
54 */ |
|
55 protected function sendHeader($header, $content) |
|
56 { |
|
57 if ($this->response) { |
|
58 $this->response->headers->set($header, $content); |
|
59 } else { |
|
60 $this->headers[$header] = $content; |
|
61 } |
|
62 } |
|
63 } |