Skip to content

Commit ba42fa0

Browse files
[Debug] cleanup interfaces before 2.5-final
1 parent 963f9ed commit ba42fa0

File tree

3 files changed

+57
-50
lines changed

3 files changed

+57
-50
lines changed
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the Symfony package.
5+
*
6+
* (c) Fabien Potencier <[email protected]>
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\Debug\ExceptionHandler;
15+
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
16+
use Symfony\Component\HttpKernel\KernelEvents;
17+
18+
/**
19+
* Configures the ExceptionHandler.
20+
*
21+
* @author Nicolas Grekas <[email protected]>
22+
*/
23+
class DebugHandlersListener implements EventSubscriberInterface
24+
{
25+
private $exceptionHandler;
26+
27+
public function __construct($exceptionHandler)
28+
{
29+
if (is_callable($exceptionHandler)) {
30+
$this->exceptionHandler = $exceptionHandler;
31+
}
32+
}
33+
34+
public function configure()
35+
{
36+
if ($this->exceptionHandler) {
37+
$mainHandler = set_exception_handler('var_dump');
38+
restore_exception_handler();
39+
if ($mainHandler instanceof ExceptionHandler) {
40+
$mainHandler->setHandler($this->exceptionHandler);
41+
}
42+
$this->exceptionHandler = null;
43+
}
44+
}
45+
46+
public static function getSubscribedEvents()
47+
{
48+
return array(KernelEvents::REQUEST => array('configure', 2048));
49+
}
50+
}

EventListener/FatalErrorExceptionsListener.php

Lines changed: 0 additions & 47 deletions
This file was deleted.

HttpKernel.php

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525
use Symfony\Component\HttpFoundation\RequestStack;
2626
use Symfony\Component\HttpFoundation\Response;
2727
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
28-
use Symfony\Component\Debug\Exception\FatalErrorException;
2928

3029
/**
3130
* HttpKernel notifies events to convert a Request object to a Response one.
@@ -87,11 +86,16 @@ public function terminate(Request $request, Response $response)
8786
}
8887

8988
/**
89+
* @throws \LogicException If the request stack is empty
90+
*
9091
* @internal
9192
*/
92-
public function handleFatalErrorException(FatalErrorException $exception)
93+
public function terminateWithException(\Exception $exception)
9394
{
94-
$request = $this->requestStack->getMasterRequest();
95+
if (!$request = $this->requestStack->getMasterRequest()) {
96+
throw new \LogicException('Request stack is empty', 0, $exception);
97+
}
98+
9599
$response = $this->handleException($exception, $request, self::MASTER_REQUEST);
96100

97101
$response->sendHeaders();

0 commit comments

Comments
 (0)