15
15
use Symfony \Component \Debug \ErrorHandler ;
16
16
use Symfony \Component \Debug \ExceptionHandler ;
17
17
use Symfony \Component \EventDispatcher \Event ;
18
- use Symfony \Component \EventDispatcher \EventDispatcherInterface ;
19
18
use Symfony \Component \EventDispatcher \EventSubscriberInterface ;
20
19
use Symfony \Component \HttpKernel \Event \KernelEvent ;
21
20
use Symfony \Component \HttpKernel \KernelEvents ;
@@ -36,6 +35,7 @@ class DebugHandlersListener implements EventSubscriberInterface
36
35
private $ throwAt ;
37
36
private $ scream ;
38
37
private $ fileLinkFormat ;
38
+ private $ firstCall = true ;
39
39
40
40
/**
41
41
* @param callable|null $exceptionHandler A handler that will be called on Exception
@@ -58,38 +58,37 @@ public function __construct($exceptionHandler, LoggerInterface $logger = null, $
58
58
/**
59
59
* Configures the error handler.
60
60
*
61
- * @param Event|null $event The triggering event
62
- * @param string|null $eventName The triggering event name
63
- * @param EventDispatcherInterface|null $eventDispatcher The dispatcher used to trigger $event
61
+ * @param Event|null $event The triggering event
64
62
*/
65
- public function configure (Event $ event = null , $ eventName = null , EventDispatcherInterface $ eventDispatcher = null )
63
+ public function configure (Event $ event = null )
66
64
{
67
- if (null !== $ eventDispatcher ) {
68
- foreach (array_keys (static ::getSubscribedEvents ()) as $ name ) {
69
- $ eventDispatcher ->removeListener ($ name , array ($ this , 'configure ' ));
70
- }
65
+ if (!$ this ->firstCall ) {
66
+ return ;
71
67
}
72
- $ handler = set_error_handler ('var_dump ' , 0 );
73
- $ handler = is_array ($ handler ) ? $ handler [0 ] : null ;
74
- restore_error_handler ();
75
- if ($ handler instanceof ErrorHandler) {
76
- if ($ this ->logger ) {
77
- $ handler ->setDefaultLogger ($ this ->logger , $ this ->levels );
78
- if (is_array ($ this ->levels )) {
79
- $ scream = 0 ;
80
- foreach ($ this ->levels as $ type => $ log ) {
81
- $ scream |= $ type ;
68
+ $ this ->firstCall = false ;
69
+ if ($ this ->logger || null !== $ this ->throwAt ) {
70
+ $ handler = set_error_handler ('var_dump ' , 0 );
71
+ $ handler = is_array ($ handler ) ? $ handler [0 ] : null ;
72
+ restore_error_handler ();
73
+ if ($ handler instanceof ErrorHandler) {
74
+ if ($ this ->logger ) {
75
+ $ handler ->setDefaultLogger ($ this ->logger , $ this ->levels );
76
+ if (is_array ($ this ->levels )) {
77
+ $ scream = 0 ;
78
+ foreach ($ this ->levels as $ type => $ log ) {
79
+ $ scream |= $ type ;
80
+ }
81
+ } else {
82
+ $ scream = null === $ this ->levels ? E_ALL | E_STRICT : $ this ->levels ;
82
83
}
83
- } else {
84
- $ scream = null === $ this ->levels ? E_ALL | E_STRICT : $ this ->levels ;
84
+ if ($ this ->scream ) {
85
+ $ handler ->screamAt ($ scream );
86
+ }
87
+ $ this ->logger = $ this ->levels = null ;
85
88
}
86
- if ($ this ->scream ) {
87
- $ handler ->screamAt ( $ scream );
89
+ if (null !== $ this ->throwAt ) {
90
+ $ handler ->throwAt ( $ this -> throwAt , true );
88
91
}
89
- $ this ->logger = $ this ->levels = null ;
90
- }
91
- if (null !== $ this ->throwAt ) {
92
- $ handler ->throwAt ($ this ->throwAt , true );
93
92
}
94
93
}
95
94
if (!$ this ->exceptionHandler ) {
0 commit comments