Skip to content

Commit bb0b224

Browse files
authored
Merge pull request #63 from ymorocutti/feature/twig-filter
Missing Twig json_decode filter
2 parents d0a5877 + f796aeb commit bb0b224

File tree

2 files changed

+6
-14
lines changed

2 files changed

+6
-14
lines changed

Resources/views/Collector/partials/auth.html.twig

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,17 +10,17 @@
1010
<td>Request</td>
1111
<td>
1212
{% if call.request and call.request.jwt|default(false) %}
13-
{{ dump(call.request.jwt.decoded.header|json_decode) }}
14-
{{ dump(call.request.jwt.decoded.payload|json_decode) }}
13+
{{ dump(call.request.jwt.decoded.header|simple_json_decode) }}
14+
{{ dump(call.request.jwt.decoded.payload|simple_json_decode) }}
1515
{% endif %}
1616
</td>
1717
</tr>
1818
<tr>
1919
<td>Response</td>
2020
<td>
2121
{% if call.response and call.response.jwt|default(false) %}
22-
{{ dump(call.response.jwt.decoded.header|json_decode) }}
23-
{{ dump(call.response.jwt.decoded.payload|json_decode) }}
22+
{{ dump(call.response.jwt.decoded.header|simple_json_decode) }}
23+
{{ dump(call.response.jwt.decoded.payload|simple_json_decode) }}
2424
{% endif %}
2525
</td>
2626
</tr>

Twig/Extension.php

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,11 @@ public function getFilters(): array
3333
new TwigFilter('simple_http_beautify', array($this, 'format'), $safe),
3434
new TwigFilter('simple_http_format_http_code', array($this, 'formatHttpCode'), $safe),
3535
new TwigFilter('simple_http_format_http_code_as_badge', array($this, 'formatHttpCodeAsSfBadge'), $safe),
36-
new TwigFilter('simple_http_md5', array($this, 'md5')),
36+
new TwigFilter('simple_http_md5', 'md5'),
3737
new TwigFilter('simple_http_include_asset', array($this, 'assetInclude'), $safe),
3838
new TwigFilter('simple_http_format_ms', array($this, 'formatMilliseconds')),
3939
new TwigFilter('simple_http_format_num', array($this, 'numberFormat')),
40+
new TwigFilter('simple_json_decode', 'json_decode'),
4041
];
4142
}
4243

@@ -72,15 +73,6 @@ public function formatMilliseconds($ms): string
7273
return $this->numberFormat($ms * 1000) . " ms";
7374
}
7475

75-
/**
76-
* @param $str
77-
* @return string
78-
*/
79-
public function md5($str): string
80-
{
81-
return md5($str);
82-
}
83-
8476
public function assetInclude(string $file): string
8577
{
8678
try {

0 commit comments

Comments
 (0)