@@ -40,8 +40,15 @@ class DumpDataCollector extends DataCollector implements DataDumperInterface
40
40
41
41
public function __construct (Stopwatch $ stopwatch = null , $ fileLinkFormat = null , $ charset = null , RequestStack $ requestStack = null , DataDumperInterface $ dumper = null )
42
42
{
43
+ $ fileLinkFormat = $ fileLinkFormat ?: ini_get ('xdebug.file_link_format ' ) ?: get_cfg_var ('xdebug.file_link_format ' );
44
+ if ($ fileLinkFormat && !is_array ($ fileLinkFormat )) {
45
+ $ i = max (strpos ($ fileLinkFormat , '%f ' ), strpos ($ fileLinkFormat , '%l ' ));
46
+ $ i = strpos ($ fileLinkFormat , '# ' , $ i ) ?: strlen ($ fileLinkFormat );
47
+ $ fileLinkFormat = array (substr ($ fileLinkFormat , 0 , $ i ), substr ($ fileLinkFormat , $ i + 1 ));
48
+ parse_str ($ fileLinkFormat [1 ], $ fileLinkFormat [1 ]);
49
+ }
43
50
$ this ->stopwatch = $ stopwatch ;
44
- $ this ->fileLinkFormat = $ fileLinkFormat ?: ini_get ( ' xdebug.file_link_format ' ) ?: get_cfg_var ( ' xdebug.file_link_format ' ) ;
51
+ $ this ->fileLinkFormat = $ fileLinkFormat ;
45
52
$ this ->charset = $ charset ?: ini_get ('php.output_encoding ' ) ?: ini_get ('default_charset ' ) ?: 'UTF-8 ' ;
46
53
$ this ->requestStack = $ requestStack ;
47
54
$ this ->dumper = $ dumper ;
@@ -149,6 +156,7 @@ public function collect(Request $request, Response $response, \Exception $except
149
156
) {
150
157
if ($ response ->headers ->has ('Content-Type ' ) && false !== strpos ($ response ->headers ->get ('Content-Type ' ), 'html ' )) {
151
158
$ this ->dumper = new HtmlDumper ('php://output ' , $ this ->charset );
159
+ $ this ->dumper ->setDisplayOptions (array ('fileLinkFormat ' => $ this ->fileLinkFormat ));
152
160
} else {
153
161
$ this ->dumper = new CliDumper ('php://output ' , $ this ->charset );
154
162
}
@@ -198,6 +206,7 @@ public function getDumps($format, $maxDepthLimit = -1, $maxItemsPerDepth = -1)
198
206
199
207
if ('html ' === $ format ) {
200
208
$ dumper = new HtmlDumper ($ data , $ this ->charset );
209
+ $ dumper ->setDisplayOptions (array ('fileLinkFormat ' => $ this ->fileLinkFormat ));
201
210
} else {
202
211
throw new \InvalidArgumentException (sprintf ('Invalid dump format: %s ' , $ format ));
203
212
}
@@ -234,6 +243,7 @@ public function __destruct()
234
243
235
244
if ('cli ' !== PHP_SAPI && stripos ($ h [$ i ], 'html ' )) {
236
245
$ this ->dumper = new HtmlDumper ('php://output ' , $ this ->charset );
246
+ $ dumper ->setDisplayOptions (array ('fileLinkFormat ' => $ this ->fileLinkFormat ));
237
247
} else {
238
248
$ this ->dumper = new CliDumper ('php://output ' , $ this ->charset );
239
249
}
@@ -258,7 +268,13 @@ private function doDump($data, $name, $file, $line)
258
268
$ name = strip_tags ($ this ->style ('' , $ name ));
259
269
$ file = strip_tags ($ this ->style ('' , $ file ));
260
270
if ($ fileLinkFormat ) {
261
- $ link = strtr (strip_tags ($ this ->style ('' , $ fileLinkFormat )), array ('%f ' => $ file , '%l ' => (int ) $ line ));
271
+ foreach ($ fileLinkFormat [1 ] as $ k => $ v ) {
272
+ if (0 === strpos ($ file , $ k )) {
273
+ $ file = substr_replace ($ file , $ v , 0 , strlen ($ k ));
274
+ break ;
275
+ }
276
+ }
277
+ $ link = strtr (strip_tags ($ this ->style ('' , $ fileLinkFormat [0 ])), array ('%f ' => $ file , '%l ' => (int ) $ line ));
262
278
$ name = sprintf ('<a href="%s" title="%s"> ' .$ s .'</a> ' , $ link , $ file , $ name );
263
279
} else {
264
280
$ name = sprintf ('<abbr title="%s"> ' .$ s .'</abbr> ' , $ file , $ name );
0 commit comments