@@ -46,13 +46,12 @@ class HtmlDumper extends CliDumper
46
46
'str .max-string-length b ' => 'color:#A0A0A0 ' ,
47
47
);
48
48
49
- protected $ displayOptions = array (
49
+ private $ displayOptions = array (
50
50
'initDepth ' => 1 ,
51
51
'maxDepth ' => 1 ,
52
52
'maxStringLength ' => 160 ,
53
53
);
54
-
55
- protected $ displayOptionsIsUpdated = false ;
54
+ private $ extraDisplayOptions = array ();
56
55
57
56
/**
58
57
* {@inheritdoc}
@@ -87,15 +86,12 @@ public function setStyles(array $styles)
87
86
/**
88
87
* Configures display options.
89
88
*
90
- * @param array $displayOptions A map of displayOptions names to customize the behavior.
89
+ * @param array $displayOptions A map of display options to customize the behavior.
91
90
*/
92
91
public function setDisplayOptions (array $ displayOptions )
93
92
{
94
- if ($ displayOptions )
95
- {
96
- $ this ->displayOptionsIsUpdated = true ;
97
- $ this ->displayOptions = $ displayOptions + $ this ->displayOptions ;
98
- }
93
+ $ this ->headerIsDumped = false ;
94
+ $ this ->displayOptions = $ displayOptions + $ this ->displayOptions ;
99
95
}
100
96
101
97
/**
@@ -123,9 +119,9 @@ public function setDumpBoundaries($prefix, $suffix)
123
119
/**
124
120
* {@inheritdoc}
125
121
*/
126
- public function dump (Data $ data , $ output = null , array $ displayOptions = [] )
122
+ public function dump (Data $ data , $ output = null , array $ extraDisplayOptions = array () )
127
123
{
128
- $ this ->setDisplayOptions ( $ displayOptions ) ;
124
+ $ this ->extraDisplayOptions = $ extraDisplayOptions ;
129
125
parent ::dump ($ data , $ output );
130
126
$ this ->dumpId = 'sf-dump- ' .mt_rand ();
131
127
}
@@ -141,7 +137,8 @@ protected function getDumpHeader()
141
137
return $ this ->dumpHeader ;
142
138
}
143
139
144
- $ line = <<<'EOHTML'
140
+ $ line = json_encode ($ this ->displayOptions , JSON_FORCE_OBJECT );
141
+ $ line = <<<EOHTML
145
142
<script>
146
143
Sfdump = window.Sfdump || (function (doc) {
147
144
@@ -218,13 +215,9 @@ function getLevelNodeForParent(parentNode, currentNode, level) {
218
215
return getLevelNodeForParent(parentNode, currentNode, level);
219
216
}
220
217
221
- return function (root, options ) {
218
+ return function (root, extraOptions ) {
222
219
root = doc.getElementById(root);
223
- EOHTML;
224
220
225
- $ line .= 'options = options || ' .json_encode ($ this ->displayOptions ).'; ' ;
226
-
227
- $ line .= <<<'EOHTML'
228
221
function a(e, f) {
229
222
addEventListener(root, e, function (e) {
230
223
if ('A' == e.target.tagName) {
@@ -285,6 +278,7 @@ function isCtrlKey(e) {
285
278
});
286
279
287
280
var indentRx = new RegExp('^('+(root.getAttribute('data-indent-pad') || ' ').replace(rxEsc, '\\$1')+')+', 'm'),
281
+ options = {$ line },
288
282
elt = root.getElementsByTagName('A'),
289
283
len = elt.length,
290
284
i = 0,
@@ -293,6 +287,10 @@ function isCtrlKey(e) {
293
287
294
288
while (i < len) t.push(elt[i++]);
295
289
290
+ for (i in extraOptions) {
291
+ options[i] = $ extraOptions [i];
292
+ }
293
+
296
294
elt = root.getElementsByTagName('SAMP');
297
295
len = elt.length;
298
296
i = 0;
@@ -378,7 +376,7 @@ function toggleMaxStringLength(elt) {
378
376
379
377
if (elt.className == 'max-string-length expanded') {
380
378
elt.className = 'max-string-length collapsed';
381
- }else{
379
+ } else {
382
380
elt.className = 'max-string-length expanded';
383
381
}
384
382
}
@@ -536,7 +534,7 @@ protected function dumpLine($depth, $endOfValue = false)
536
534
$ this ->line .= sprintf (
537
535
$ this ->dumpSuffix ,
538
536
$ this ->dumpId ,
539
- $ this ->displayOptionsIsUpdated ? ', ' .json_encode ($ this ->displayOptions ) : ''
537
+ $ this ->extraDisplayOptions ? ', ' .json_encode ($ this ->extraDisplayOptions ) : ''
540
538
);
541
539
}
542
540
$ this ->lastDepth = $ depth ;
0 commit comments