X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=src%2FWallabag%2FCoreBundle%2FTwig%2FWallabagExtension.php;h=47af3c8ec69afb6028bd5b08f05a488b5af5c2a5;hb=33e3eeaec851158289e1a236cfe08a475cc6364a;hp=02f17f50a58b52b2dc5d0b6c2af765e58506ecef;hpb=62107f50d3b43039a635dcaecce317ef0299ee1f;p=github%2Fwallabag%2Fwallabag.git 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 private $tagRepository; private $lifeTime; private $translator; + private $rootDir; - public function __construct(EntryRepository $entryRepository, TagRepository $tagRepository, TokenStorageInterface $tokenStorage, $lifeTime, TranslatorInterface $translator) + public function __construct(EntryRepository $entryRepository, TagRepository $tagRepository, TokenStorageInterface $tokenStorage, $lifeTime, TranslatorInterface $translator, string $rootDir) { $this->entryRepository = $entryRepository; $this->tagRepository = $tagRepository; $this->tokenStorage = $tokenStorage; $this->lifeTime = $lifeTime; $this->translator = $translator; + $this->rootDir = $rootDir; } public function getGlobals() @@ -48,6 +50,7 @@ class WallabagExtension extends AbstractExtension implements GlobalsInterface new TwigFunction('count_entries', [$this, 'countEntries']), new TwigFunction('count_tags', [$this, 'countTags']), new TwigFunction('display_stats', [$this, 'displayStats']), + new TwigFunction('asset_file_exists', [$this, 'assetFileExists']), ]; } @@ -165,6 +168,11 @@ class WallabagExtension extends AbstractExtension implements GlobalsInterface ]); } + public function assetFileExists($name) + { + return file_exists(realpath($this->rootDir . '/../web/' . $name)); + } + public function getName() { return 'wallabag_extension';