20
20
use Symfony \Component \VarDumper \Dumper \CliDumper ;
21
21
use Symfony \Component \VarDumper \Dumper \HtmlDumper ;
22
22
use Symfony \Component \VarDumper \Dumper \DataDumperInterface ;
23
+ use Symfony \Component \VarDumper \Dumper \ServerDumper ;
23
24
use Twig \Template ;
24
25
25
26
/**
@@ -38,15 +39,17 @@ class DumpDataCollector extends DataCollector implements DataDumperInterface
38
39
private $ requestStack ;
39
40
private $ dumper ;
40
41
private $ dumperIsInjected ;
42
+ private $ serverDumper ;
41
43
42
- public function __construct (Stopwatch $ stopwatch = null , $ fileLinkFormat = null , $ charset = null , RequestStack $ requestStack = null , DataDumperInterface $ dumper = null )
44
+ public function __construct (Stopwatch $ stopwatch = null , $ fileLinkFormat = null , $ charset = null , RequestStack $ requestStack = null , DataDumperInterface $ dumper = null , ServerDumper $ serverDumper = null )
43
45
{
44
46
$ this ->stopwatch = $ stopwatch ;
45
47
$ this ->fileLinkFormat = $ fileLinkFormat ?: ini_get ('xdebug.file_link_format ' ) ?: get_cfg_var ('xdebug.file_link_format ' );
46
48
$ this ->charset = $ charset ?: ini_get ('php.output_encoding ' ) ?: ini_get ('default_charset ' ) ?: 'UTF-8 ' ;
47
49
$ this ->requestStack = $ requestStack ;
48
50
$ this ->dumper = $ dumper ;
49
51
$ this ->dumperIsInjected = null !== $ dumper ;
52
+ $ this ->serverDumper = $ serverDumper ;
50
53
51
54
// All clones share these properties by reference:
52
55
$ this ->rootRefs = array (
@@ -257,8 +260,17 @@ public function __destruct()
257
260
258
261
private function doDump ($ data , $ name , $ file , $ line )
259
262
{
263
+ $ dumper = $ this ->serverDumper ?: $ this ->dumper ;
264
+ if ($ dumper instanceof ServerDumper) {
265
+ $ dumper ->setWrappedDumper ($ this ->dumper );
266
+ }
267
+
260
268
if ($ this ->dumper instanceof CliDumper) {
261
269
$ contextDumper = function ($ name , $ file , $ line , $ fmt ) {
270
+ if ($ this instanceof ServerDumper) {
271
+ return ;
272
+ }
273
+
262
274
if ($ this instanceof HtmlDumper) {
263
275
if ($ file ) {
264
276
$ s = $ this ->style ('meta ' , '%s ' );
@@ -278,13 +290,13 @@ private function doDump($data, $name, $file, $line)
278
290
}
279
291
$ this ->dumpLine (0 );
280
292
};
281
- $ contextDumper = $ contextDumper ->bindTo ($ this -> dumper , $ this -> dumper );
293
+ $ contextDumper = $ contextDumper ->bindTo ($ dumper , $ dumper );
282
294
$ contextDumper ($ name , $ file , $ line , $ this ->fileLinkFormat );
283
295
} else {
284
296
$ cloner = new VarCloner ();
285
- $ this -> dumper ->dump ($ cloner ->cloneVar ($ name .' on line ' .$ line .': ' ));
297
+ $ dumper ->dump ($ cloner ->cloneVar ($ name .' on line ' .$ line .': ' ));
286
298
}
287
- $ this -> dumper ->dump ($ data );
299
+ $ dumper ->dump ($ data );
288
300
}
289
301
290
302
private function htmlEncode ($ s )
0 commit comments