]>
git.immae.eu Git - github/wallabag/wallabag.git/blob - vendor/umpirsky/twig-gettext-extractor/Twig/Gettext/Loader/Filesystem.php
b011b032421f9b529968df457aae34a4ee44502e
4 * This file is part of the Twig Gettext utility.
6 * (c) Саша Стаменковић <umpirsky@gmail.com>
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
12 namespace Twig\Gettext\Loader
;
15 * Loads template from the filesystem.
17 * @author Саша Стаменковић <umpirsky@gmail.com>
19 class Filesystem
extends \Twig_Loader_Filesystem
22 * Hacked find template to allow loading templates by absolute path.
24 * @param string $name template name or absolute path
26 protected function findTemplate($name)
29 $name = preg_replace('#/{2,}#', '/', strtr($name, '\\', '/'));
31 if (isset($this->cache
[$name])) {
32 return $this->cache
[$name];
35 $this->validateName($name);
37 $namespace = '__main__';
38 if (isset($name[0]) && '@' == $name[0]) {
39 if (false === $pos = strpos($name, '/')) {
40 throw new \
InvalidArgumentException(sprintf('Malformed namespaced template name "%s" (expecting "@namespace/template_name").', $name));
43 $namespace = substr($name, 1, $pos - 1);
45 $name = substr($name, $pos +
1);
48 if (!isset($this->paths
[$namespace])) {
49 throw new \
Twig_Error_Loader(sprintf('There are no registered paths for namespace "%s".', $namespace));
53 return $this->cache
[$name] = $name;
56 return __DIR__
.'/../Test/Fixtures/twig/empty.twig';