Skip to content

Commit 777a89b

Browse files
QuentinNanomonxroukmoute
authored andcommitted
Switch from \twig_extension to AbstractExtension (#11)
Support twig 3
1 parent 8df6e4d commit 777a89b

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
"bossa/phpspec2-expect": "^3.0",
3131
"phpspec/phpspec": "^4.3",
3232
"roave/security-advisories": "dev-master",
33-
"twig/twig": "^2.4"
33+
"twig/twig": "^2.7"
3434
},
3535
"extra": {
3636
"branch-alias": {

src/Twig/HashidsExtension.php

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,10 @@
55
namespace Roukmoute\HashidsBundle\Twig;
66

77
use Roukmoute\HashidsBundle\Hashids;
8+
use Twig\Extension\AbstractExtension;
9+
use Twig\TwigFilter;
810

9-
class HashidsExtension extends \Twig_Extension
11+
class HashidsExtension extends AbstractExtension
1012
{
1113
/**
1214
* @var Hashids
@@ -21,8 +23,8 @@ public function __construct(Hashids $hashids)
2123
public function getFilters(): array
2224
{
2325
return [
24-
new \Twig_SimpleFilter('hashids_encode', [$this, 'encode']),
25-
new \Twig_SimpleFilter('hashids_decode', [$this, 'decode']),
26+
new TwigFilter('hashids_encode', [$this, 'encode']),
27+
new TwigFilter('hashids_decode', [$this, 'decode']),
2628
];
2729
}
2830

0 commit comments

Comments
 (0)