1 | <?php |
||
23 | class Loader implements \Twig_LoaderInterface, \Twig_ExistsLoaderInterface, \Twig_SourceContextLoaderInterface |
||
24 | { |
||
25 | |||
26 | /** |
||
27 | * Get the file contents of a template. |
||
28 | * |
||
29 | * @param string $name Template. |
||
30 | * |
||
31 | * @return string |
||
32 | */ |
||
33 | 2 | public function getSource($name) |
|
38 | |||
39 | /** |
||
40 | * Get cache key for template. |
||
41 | * |
||
42 | * @param string $name Template. |
||
43 | * |
||
44 | * @return string |
||
45 | */ |
||
46 | 13 | public function getCacheKey($name) |
|
50 | |||
51 | /** |
||
52 | * Check if template is still fresh. |
||
53 | * |
||
54 | * @param string $name Template. |
||
55 | * @param integer $time Timestamp. |
||
56 | * |
||
57 | * @return boolean |
||
58 | */ |
||
59 | 2 | public function isFresh($name, $time) |
|
64 | |||
65 | /** |
||
66 | * Resolve template name to filename. |
||
67 | * |
||
68 | * @param string $name Template. |
||
69 | * |
||
70 | * @return string |
||
71 | * |
||
72 | * @throws \Twig_Error_Loader Thrown when template file isn't found. |
||
73 | */ |
||
74 | // @codingStandardsIgnoreStart |
||
75 | 17 | protected function resolveFileName($name) |
|
76 | { |
||
77 | // @codingStandardsIgnoreEnd |
||
78 | 17 | if (file_exists($name)) { |
|
79 | 11 | return $name; |
|
80 | } |
||
81 | |||
82 | 6 | list($plugin, $file) = pluginSplit($name); |
|
83 | foreach ([ |
||
84 | 6 | null, |
|
85 | 6 | $plugin, |
|
86 | 6 | ] as $scope) { |
|
87 | 6 | $paths = $this->getPaths($scope); |
|
88 | 6 | foreach ($paths as $path) { |
|
89 | 6 | $filePath = $path . $file; |
|
90 | 6 | if (file_exists($filePath)) { |
|
91 | 2 | return $filePath; |
|
92 | } |
||
93 | |||
94 | 6 | $filePath = $path . $file . TwigView::EXT; |
|
95 | 6 | if (file_exists($filePath)) { |
|
96 | 3 | return $filePath; |
|
97 | } |
||
98 | 5 | } |
|
99 | 5 | } |
|
100 | |||
101 | 3 | throw new \Twig_Error_Loader(sprintf('Template "%s" is not defined.', $name)); |
|
102 | } |
||
103 | |||
104 | /** |
||
105 | * Check if $plugin is active and return it's template paths or return the aps template paths. |
||
106 | * |
||
107 | * @param string|null $plugin The plugin in question. |
||
108 | * |
||
109 | * @return array |
||
110 | */ |
||
111 | 6 | protected function getPaths($plugin) |
|
119 | |||
120 | public function exists($name) |
||
126 | |||
127 | 6 | public function getSourceContext($name) |
|
133 | } |
||
134 |