1 | <?php |
||
4 | class Template |
||
5 | { |
||
6 | /** @var Callables */ |
||
7 | private $callables; |
||
8 | |||
9 | /** @var Resolver */ |
||
10 | private $resolver; |
||
11 | |||
12 | /** |
||
13 | * Template constructor. |
||
14 | * |
||
15 | * @param Callables|null $callables If NULL then an empty Callables will be created |
||
16 | * @param Resolver|null $resolver If NULL then a basic Resolver will be created |
||
17 | */ |
||
18 | 16 | public function __construct(Callables $callables = null, Resolver $resolver = null) |
|
23 | |||
24 | /** |
||
25 | * Retrieve the Callables object |
||
26 | * |
||
27 | * @return Callables |
||
28 | */ |
||
29 | 4 | public function callables() |
|
33 | |||
34 | /** |
||
35 | * Retrieve the Resolver object |
||
36 | * |
||
37 | * @return Resolver |
||
38 | */ |
||
39 | 3 | public function resolver() |
|
43 | |||
44 | /** |
||
45 | * Magic method to export calls to $this into calls to Callables |
||
46 | * |
||
47 | * @param string $name |
||
48 | * @param mixed $arguments |
||
49 | * @return string |
||
50 | */ |
||
51 | 1 | public function __call($name, $arguments) |
|
55 | |||
56 | /** |
||
57 | * Retrieve if a resolved file is a valid template |
||
58 | * If return FALSE then the $errorMessage variable is populated |
||
59 | * |
||
60 | * @param string $templateFilename |
||
61 | * @param string $errorMessage |
||
62 | * @return bool |
||
63 | */ |
||
64 | 11 | public function isValidTemplateFilename($templateFilename, &$errorMessage = '') |
|
80 | |||
81 | /** |
||
82 | * Fetch and return the content of a templates passing the specified variables. |
||
83 | * Inside the template the variable $this refer to exactly this template object |
||
84 | * |
||
85 | * @param string $templateName |
||
86 | * @param array $templateVariables |
||
87 | * @return string |
||
88 | */ |
||
89 | 8 | public function fetch($templateName, array $templateVariables = []) |
|
105 | } |
||
106 |