diff options
Diffstat (limited to 'src/Wallabag/CoreBundle/Twig')
-rw-r--r-- | src/Wallabag/CoreBundle/Twig/WallabagExtension.php | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/src/Wallabag/CoreBundle/Twig/WallabagExtension.php b/src/Wallabag/CoreBundle/Twig/WallabagExtension.php index 02f17f50..47af3c8e 100644 --- a/src/Wallabag/CoreBundle/Twig/WallabagExtension.php +++ b/src/Wallabag/CoreBundle/Twig/WallabagExtension.php | |||
@@ -18,14 +18,16 @@ class WallabagExtension extends AbstractExtension implements GlobalsInterface | |||
18 | private $tagRepository; | 18 | private $tagRepository; |
19 | private $lifeTime; | 19 | private $lifeTime; |
20 | private $translator; | 20 | private $translator; |
21 | private $rootDir; | ||
21 | 22 | ||
22 | public function __construct(EntryRepository $entryRepository, TagRepository $tagRepository, TokenStorageInterface $tokenStorage, $lifeTime, TranslatorInterface $translator) | 23 | public function __construct(EntryRepository $entryRepository, TagRepository $tagRepository, TokenStorageInterface $tokenStorage, $lifeTime, TranslatorInterface $translator, string $rootDir) |
23 | { | 24 | { |
24 | $this->entryRepository = $entryRepository; | 25 | $this->entryRepository = $entryRepository; |
25 | $this->tagRepository = $tagRepository; | 26 | $this->tagRepository = $tagRepository; |
26 | $this->tokenStorage = $tokenStorage; | 27 | $this->tokenStorage = $tokenStorage; |
27 | $this->lifeTime = $lifeTime; | 28 | $this->lifeTime = $lifeTime; |
28 | $this->translator = $translator; | 29 | $this->translator = $translator; |
30 | $this->rootDir = $rootDir; | ||
29 | } | 31 | } |
30 | 32 | ||
31 | public function getGlobals() | 33 | public function getGlobals() |
@@ -48,6 +50,7 @@ class WallabagExtension extends AbstractExtension implements GlobalsInterface | |||
48 | new TwigFunction('count_entries', [$this, 'countEntries']), | 50 | new TwigFunction('count_entries', [$this, 'countEntries']), |
49 | new TwigFunction('count_tags', [$this, 'countTags']), | 51 | new TwigFunction('count_tags', [$this, 'countTags']), |
50 | new TwigFunction('display_stats', [$this, 'displayStats']), | 52 | new TwigFunction('display_stats', [$this, 'displayStats']), |
53 | new TwigFunction('asset_file_exists', [$this, 'assetFileExists']), | ||
51 | ]; | 54 | ]; |
52 | } | 55 | } |
53 | 56 | ||
@@ -165,6 +168,11 @@ class WallabagExtension extends AbstractExtension implements GlobalsInterface | |||
165 | ]); | 168 | ]); |
166 | } | 169 | } |
167 | 170 | ||
171 | public function assetFileExists($name) | ||
172 | { | ||
173 | return file_exists(realpath($this->rootDir . '/../web/' . $name)); | ||
174 | } | ||
175 | |||
168 | public function getName() | 176 | public function getName() |
169 | { | 177 | { |
170 | return 'wallabag_extension'; | 178 | return 'wallabag_extension'; |