1 | <?php |
||
15 | class FlysystemLoader implements Twig_LoaderInterface |
||
16 | { |
||
17 | /** |
||
18 | * @var Filesystem |
||
19 | */ |
||
20 | private $filesystem; |
||
21 | |||
22 | /** |
||
23 | * @var string |
||
24 | */ |
||
25 | private $templatePath; |
||
26 | |||
27 | /** |
||
28 | * FlysystemLoader constructor. |
||
29 | * |
||
30 | * @param Filesystem $filesystem |
||
31 | * @param string $templatePath |
||
32 | */ |
||
33 | 15 | public function __construct(Filesystem $filesystem, $templatePath = '') |
|
38 | |||
39 | /** |
||
40 | * Gets the source code of a template, given its name. |
||
41 | * |
||
42 | * @param string $name The name of the template to load |
||
43 | * |
||
44 | * @return string The template source code |
||
45 | * |
||
46 | * @throws Twig_Error_Loader When $name is not found |
||
47 | */ |
||
48 | 9 | public function getSource($name) |
|
54 | |||
55 | /** |
||
56 | * Checks if the underlying flysystem contains a file of the given name. |
||
57 | * |
||
58 | * @param string $name |
||
59 | * |
||
60 | * @return \League\Flysystem\File|\League\Flysystem\Handler |
||
61 | * @throws Twig_Error_Loader |
||
62 | */ |
||
63 | 15 | protected function getFileOrFail($name) |
|
76 | |||
77 | /** |
||
78 | * Gets the cache key to use for the cache for a given template name. |
||
79 | * |
||
80 | * @param string $name The name of the template to load |
||
81 | * |
||
82 | * @return string The cache key |
||
83 | * |
||
84 | * @throws Twig_Error_Loader When $name is not found |
||
85 | */ |
||
86 | 3 | public function getCacheKey($name) |
|
92 | |||
93 | /** |
||
94 | * Returns true if the template is still fresh. |
||
95 | * |
||
96 | * @param string $name The template name |
||
97 | * @param int $time Timestamp of the last modification time of the |
||
98 | * cached template |
||
99 | * |
||
100 | * @return bool true if the template is fresh, false otherwise |
||
101 | * |
||
102 | * @throws Twig_Error_Loader When $name is not found |
||
103 | */ |
||
104 | 3 | public function isFresh($name, $time) |
|
110 | |||
111 | /** |
||
112 | * @param string $name |
||
113 | * |
||
114 | * @return string |
||
115 | */ |
||
116 | 15 | protected function resolveTemplateName($name) |
|
125 | } |
||
126 |