1 | <?php |
||
24 | abstract class AbstractEngine implements |
||
25 | EngineInterface, |
||
26 | LoggerAwareInterface |
||
27 | { |
||
28 | use LoggerAwareTrait; |
||
29 | |||
30 | /** |
||
31 | * @var LoaderInterface |
||
32 | */ |
||
33 | private $loader; |
||
34 | |||
35 | /** |
||
36 | * The cache option. |
||
37 | * |
||
38 | * @var mixed |
||
39 | */ |
||
40 | private $cache; |
||
41 | |||
42 | /** |
||
43 | * @return string |
||
44 | */ |
||
45 | abstract public function type(); |
||
46 | |||
47 | /** |
||
48 | * Build the object with an array of dependencies. |
||
49 | * |
||
50 | * ## Required parameters: |
||
51 | * - `logger` a PSR-3 logger |
||
52 | * - `loader` a Loader object, to load templates. |
||
53 | * |
||
54 | * @param array $data Engine dependencie. |
||
55 | */ |
||
56 | public function __construct(array $data) |
||
65 | |||
66 | /** |
||
67 | * Set the engine's cache implementation. |
||
68 | * |
||
69 | * @param mixed $cache A engine cache implementation, |
||
70 | * an absolute path to the compiled views, |
||
71 | * a boolean to enable/disable cache. |
||
72 | * @return void |
||
73 | */ |
||
74 | protected function setCache($cache) |
||
78 | |||
79 | /** |
||
80 | * Get the engine's cache implementation. |
||
81 | * |
||
82 | * @return mixed |
||
83 | */ |
||
84 | protected function cache() |
||
88 | |||
89 | /** |
||
90 | * @param LoaderInterface $loader A loader instance. |
||
91 | * @return void |
||
92 | */ |
||
93 | private function setLoader(LoaderInterface $loader) |
||
97 | |||
98 | /** |
||
99 | * @return LoaderInterface |
||
100 | */ |
||
101 | protected function loader() |
||
105 | |||
106 | /** |
||
107 | * Delegates template loading to the engine's Loader object. |
||
108 | * |
||
109 | * @param string $templateIdent The template identifier to load. |
||
110 | * @return string The template string, loaded from identifier. |
||
111 | */ |
||
112 | public function loadTemplate($templateIdent) |
||
116 | |||
117 | /** |
||
118 | * Render a template (from ident) with a given context. |
||
119 | * |
||
120 | * @param string $templateIdent The template identifier to load and render. |
||
121 | * @param mixed $context The rendering context. |
||
122 | * @return string The rendered template string. |
||
123 | */ |
||
124 | public function render($templateIdent, $context) |
||
129 | |||
130 | /** |
||
131 | * @param string $templateString The template string to render. |
||
132 | * @param mixed $context The rendering context. |
||
133 | * @return string The rendered template string. |
||
134 | */ |
||
135 | abstract public function renderTemplate($templateString, $context); |
||
136 | |||
137 | /** |
||
138 | * @param string $varName The name of the variable to set this template unto. |
||
139 | * @param string|null $templateIdent The "dynamic template" to set. null to clear. |
||
140 | * @return void |
||
141 | */ |
||
142 | public function setDynamicTemplate($varName, $templateIdent) |
||
146 | } |
||
147 |