From a2f4efe6d2a90d8a2b84a275f48a07dc8aa0a84f Mon Sep 17 00:00:00 2001 From: Jeremy Benoist Date: Fri, 21 Jun 2019 12:46:53 +0200 Subject: Use Twig 2.0 `mnapoli/piwik-twig-extension` locked Twig to the 1.10 version. The new version is compatible with Twig 2.0 --- src/Wallabag/CoreBundle/Twig/WallabagExtension.php | 23 +++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) (limited to 'src/Wallabag/CoreBundle/Twig') diff --git a/src/Wallabag/CoreBundle/Twig/WallabagExtension.php b/src/Wallabag/CoreBundle/Twig/WallabagExtension.php index 536185d4..02f17f50 100644 --- a/src/Wallabag/CoreBundle/Twig/WallabagExtension.php +++ b/src/Wallabag/CoreBundle/Twig/WallabagExtension.php @@ -4,10 +4,14 @@ namespace Wallabag\CoreBundle\Twig; use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface; use Symfony\Component\Translation\TranslatorInterface; +use Twig\Extension\AbstractExtension; +use Twig\Extension\GlobalsInterface; +use Twig\TwigFilter; +use Twig\TwigFunction; use Wallabag\CoreBundle\Repository\EntryRepository; use Wallabag\CoreBundle\Repository\TagRepository; -class WallabagExtension extends \Twig_Extension implements \Twig_Extension_GlobalsInterface +class WallabagExtension extends AbstractExtension implements GlobalsInterface { private $tokenStorage; private $entryRepository; @@ -24,21 +28,26 @@ class WallabagExtension extends \Twig_Extension implements \Twig_Extension_Globa $this->translator = $translator; } + public function getGlobals() + { + return []; + } + public function getFilters() { return [ - new \Twig_SimpleFilter('removeWww', [$this, 'removeWww']), - new \Twig_SimpleFilter('removeScheme', [$this, 'removeScheme']), - new \Twig_SimpleFilter('removeSchemeAndWww', [$this, 'removeSchemeAndWww']), + new TwigFilter('removeWww', [$this, 'removeWww']), + new TwigFilter('removeScheme', [$this, 'removeScheme']), + new TwigFilter('removeSchemeAndWww', [$this, 'removeSchemeAndWww']), ]; } public function getFunctions() { return [ - new \Twig_SimpleFunction('count_entries', [$this, 'countEntries']), - new \Twig_SimpleFunction('count_tags', [$this, 'countTags']), - new \Twig_SimpleFunction('display_stats', [$this, 'displayStats']), + new TwigFunction('count_entries', [$this, 'countEntries']), + new TwigFunction('count_tags', [$this, 'countTags']), + new TwigFunction('display_stats', [$this, 'displayStats']), ]; } -- cgit v1.2.3