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 | */ |
||
32 | 15 | public function __construct(Filesystem $filesystem, $templatePath = '') |
|
37 | |||
38 | /** |
||
39 | * Gets the source code of a template, given its name. |
||
40 | * |
||
41 | * @param string $name The name of the template to load |
||
42 | * |
||
43 | * @return string The template source code |
||
44 | * |
||
45 | * @throws Twig_Error_Loader When $name is not found |
||
46 | */ |
||
47 | 9 | public function getSource($name) |
|
53 | |||
54 | /** |
||
55 | * Checks if the underlying flysystem contains a file of the given name. |
||
56 | * |
||
57 | * @param string $name |
||
58 | * |
||
59 | * @return \League\Flysystem\File|\League\Flysystem\Handler |
||
60 | * @throws Twig_Error_Loader |
||
61 | */ |
||
62 | 15 | protected function getFileOrFail($name) |
|
75 | |||
76 | /** |
||
77 | * Gets the cache key to use for the cache for a given template name. |
||
78 | * |
||
79 | * @param string $name The name of the template to load |
||
80 | * |
||
81 | * @return string The cache key |
||
82 | * |
||
83 | * @throws Twig_Error_Loader When $name is not found |
||
84 | */ |
||
85 | 3 | public function getCacheKey($name) |
|
91 | |||
92 | /** |
||
93 | * Returns true if the template is still fresh. |
||
94 | * |
||
95 | * @param string $name The template name |
||
96 | * @param int $time Timestamp of the last modification time of the |
||
97 | * cached template |
||
98 | * |
||
99 | * @return bool true if the template is fresh, false otherwise |
||
100 | * |
||
101 | * @throws Twig_Error_Loader When $name is not found |
||
102 | */ |
||
103 | 3 | public function isFresh($name, $time) |
|
109 | |||
110 | /** |
||
111 | * @param string $name |
||
112 | * |
||
113 | * @return string |
||
114 | */ |
||
115 | 15 | protected function resolveTemplateName($name) |
|
124 | } |
||
125 |