1 | <?php |
||
9 | class Builder { |
||
10 | private $template; |
||
11 | private $tss; |
||
12 | private $cache; |
||
13 | private $time; |
||
14 | private $modules = []; |
||
15 | private $config; |
||
16 | private $filePath; |
||
17 | private $defaultModules = [ |
||
18 | '\\Transphporm\\Module\\Basics', |
||
19 | '\\Transphporm\\Module\\Pseudo', |
||
20 | '\\Transphporm\\Module\\Format', |
||
21 | '\\Transphporm\\Module\\Functions' |
||
22 | ]; |
||
23 | |||
24 | public function __construct($template, $tss = '', $modules = null) { |
||
25 | $this->template = $template; |
||
26 | $this->tss = $tss; |
||
27 | $this->cache = new Cache(new \ArrayObject()); |
||
28 | $this->filePath = new FilePath(); |
||
29 | $modules = is_array($modules) ? $modules : $this->defaultModules; |
||
30 | foreach ($modules as $module) $this->loadModule(new $module); |
||
31 | } |
||
32 | |||
33 | //Allow setting the time used by Transphporm for caching. This is for testing purposes |
||
34 | //Would be better if PHP allowed setting the script clock, but this is the simplest way of overriding it |
||
35 | public function setTime($time) { |
||
38 | |||
39 | public function loadModule(Module $module) { |
||
42 | |||
43 | public function setLocale($locale) { |
||
44 | $format = new \Transphporm\Module\Format($locale); |
||
45 | $this->modules[get_class($format)] = $format; |
||
46 | } |
||
47 | |||
48 | public function addPath($dir) { |
||
51 | |||
52 | public function output($data = null, $document = false) { |
||
73 | |||
74 | private function createAndProcessTemplate($data, $body, &$headers) { |
||
86 | |||
87 | //Add a postprocessing hook. This cleans up anything transphporm has added to the markup which needs to be removed |
||
88 | private function doPostProcessing($template) { |
||
92 | |||
93 | |||
94 | //Load a template, firstly check if it's a file or a valid string |
||
95 | private function loadTemplate() { |
||
100 | |||
101 | private function loadTemplateFromFile($file) { |
||
105 | |||
106 | public function setCache(\ArrayAccess $cache) { |
||
109 | |||
110 | private function isValidDoc($xml) { |
||
113 | |||
114 | public function __destruct() { |
||
118 | } |
||
119 |
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.