first commit
This commit is contained in:
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
namespace App\Libraries\Twig;
|
||||
|
||||
use Twig\Extension\AbstractExtension;
|
||||
use Twig\TwigFilter;
|
||||
|
||||
class TwigJsonDecodeExtension extends AbstractExtension
|
||||
{
|
||||
public function getFilters(): array
|
||||
{
|
||||
return [
|
||||
new TwigFilter('json_decode', [$this, 'jsonDecode']),
|
||||
];
|
||||
}
|
||||
|
||||
public function jsonDecode(string $json, bool $assoc = true, int $depth = 512, int $flags = 0)
|
||||
{
|
||||
return json_decode($json, $assoc, $depth, $flags);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user