1 | <?php |
||
8 | class Template |
||
9 | { |
||
10 | const DEFINITION_FILE = 'def.json'; |
||
11 | const MAIN_FILE = 'main.tpl'; |
||
12 | |||
13 | protected $name; |
||
14 | protected $path; |
||
15 | protected $parsedDefinition; |
||
16 | |||
17 | /* |
||
18 | * Returns the name of the template |
||
19 | * |
||
20 | * @return string |
||
21 | */ |
||
22 | |||
23 | 3 | public function getName() |
|
27 | |||
28 | /** |
||
29 | * Sets the name of the template |
||
30 | * |
||
31 | * @param string $name |
||
32 | */ |
||
33 | 16 | public function setName($name) |
|
37 | |||
38 | /** |
||
39 | * Returns the absolute path for the template |
||
40 | * |
||
41 | * @return string |
||
42 | */ |
||
43 | 17 | public function getPath() |
|
47 | |||
48 | /** |
||
49 | * Sets the path of the template |
||
50 | * |
||
51 | * @param string $path |
||
52 | * @throws PathNotFoundException |
||
53 | */ |
||
54 | 19 | public function setPath($path) |
|
65 | |||
66 | /** |
||
67 | * Returns the definition of the template. If it is not parsed yet, it will call parseDefinition to parse it. |
||
68 | * |
||
69 | * @return array |
||
70 | */ |
||
71 | 2 | public function getParsedDefinition() |
|
78 | |||
79 | /** |
||
80 | * Constructor with no parameters needed |
||
81 | */ |
||
82 | 22 | public function __construct() |
|
86 | |||
87 | /** |
||
88 | * Returns the path to the definition file |
||
89 | * |
||
90 | * @return string |
||
91 | */ |
||
92 | 13 | public function getDefinitionFile() |
|
96 | |||
97 | /** |
||
98 | * Returns the path to the main file |
||
99 | * |
||
100 | * @param boolean $withPath if false, will return just the main file |
||
101 | * @return string |
||
102 | */ |
||
103 | 10 | public function getMainFile($withPath = true) |
|
107 | |||
108 | /** |
||
109 | * Returns true if it is a valid template |
||
110 | * |
||
111 | * @return boolean |
||
112 | */ |
||
113 | 13 | public function isValid() |
|
129 | |||
130 | /** |
||
131 | * Returns the defined assets + assets in the template folder |
||
132 | * |
||
133 | * @param string $extension |
||
134 | * @return Array |
||
135 | */ |
||
136 | 2 | public function getAssets($extension, Array $excludes = null) |
|
144 | |||
145 | /** |
||
146 | * Searchs for assets inside the template path |
||
147 | * |
||
148 | * @param string $extension |
||
149 | * @return Array |
||
150 | */ |
||
151 | 3 | public function searchAssets($extension, Array $excludes = null) |
|
156 | |||
157 | /** |
||
158 | * Returns an array with the defined assets given an extension |
||
159 | * |
||
160 | * @param string $extension |
||
161 | * @return Array |
||
162 | */ |
||
163 | 3 | public function getDefinedAssets($extension) |
|
177 | |||
178 | /** |
||
179 | * Parses the definition file |
||
180 | * |
||
181 | * @return Array |
||
182 | */ |
||
183 | 4 | protected function parseDefinition() |
|
188 | } |