From 7bc09d1c4ce16727ee23aab00bb484f75e90fe36 Mon Sep 17 00:00:00 2001 From: Philipp Wahala Date: Mon, 5 Aug 2013 10:12:29 +0200 Subject: [PATCH] Overwrite exist method of Twig FilesystemLoader (2.2) - Implement exist method for the Symfony\Bundle\TwigBundle\Loader\FilesystemLoader to allow bundle syntax for templates --- .../TwigBundle/Loader/FilesystemLoader.php | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/src/Symfony/Bundle/TwigBundle/Loader/FilesystemLoader.php b/src/Symfony/Bundle/TwigBundle/Loader/FilesystemLoader.php index 64d5616c5ffd2..ff2b84a11c502 100644 --- a/src/Symfony/Bundle/TwigBundle/Loader/FilesystemLoader.php +++ b/src/Symfony/Bundle/TwigBundle/Loader/FilesystemLoader.php @@ -40,6 +40,25 @@ public function __construct(FileLocatorInterface $locator, TemplateNameParserInt $this->cache = array(); } + /** + * {@inheritdoc} + */ + public function exists($name) + { + // for BC + if ($this->doFindTemplate($name)) { + return true; + } + + try { + $this->findTemplate($name); + + return true; + } catch (\Twig_Error_Loader $e) { + return false; + } + } + /** * Returns the path to the template file. *