1 | <?php |
||
17 | class PageParser |
||
18 | { |
||
19 | |||
20 | /** |
||
21 | * @var ParserFactory |
||
22 | */ |
||
23 | private $parserFactory; |
||
24 | |||
25 | /** |
||
26 | * @var MetaCompiler |
||
27 | */ |
||
28 | private $metaCompiler; |
||
29 | |||
30 | /** |
||
31 | * @var TemplatePlugin |
||
32 | */ |
||
33 | private $templatePlugin; |
||
34 | |||
35 | /** |
||
36 | * @var string |
||
37 | */ |
||
38 | private $templateDir; |
||
39 | |||
40 | /** |
||
41 | * @var AdapterFactory |
||
42 | */ |
||
43 | private $adapterFactory; |
||
44 | |||
45 | /** |
||
46 | * @var HeaderCompiler|null |
||
47 | */ |
||
48 | private $headerCompiler; |
||
49 | |||
50 | public function __construct( |
||
70 | |||
71 | /** |
||
72 | * Load all templates from either the `directories.template` directory. Depending on the configured template |
||
73 | * engine, set with `engines.template`; .html or .tpl files will be loaded. |
||
74 | * |
||
75 | * @return SplFileInfo[] |
||
76 | */ |
||
77 | public function loadTemplates() { |
||
91 | |||
92 | /** |
||
93 | * @param Page $page |
||
94 | * |
||
95 | * @return string |
||
96 | */ |
||
97 | public function parsePage(Page $page) : string { |
||
115 | |||
116 | /** |
||
117 | * This function takes a page and optional entry id. The page's adapters will be loaded and looped. |
||
118 | * An adapter will transform a page's original configuration and variables to one or more pages. |
||
119 | * An entry id can be provided as a filter. This filter can be used in an adapter to skip rendering unnecessary |
||
120 | * pages. The filter parameter is used to render pages on the fly when using the developer controller. |
||
121 | * |
||
122 | * @param Page $page |
||
123 | * @param string $entryId |
||
124 | * |
||
125 | * @return Page[] |
||
126 | * |
||
127 | * @see \Brendt\Stitcher\Adapter\Adapter::transform() |
||
128 | * @see \Brendt\Stitcher\Application\DevController::run() |
||
129 | */ |
||
130 | public function parseAdapters(Page $page, $entryId = null) { |
||
149 | |||
150 | /** |
||
151 | * This function takes a Page object and parse its variables using a Parser. It will only parse variables which |
||
152 | * weren't parsed already by an adapter. |
||
153 | * |
||
154 | * @param Page $page |
||
155 | * |
||
156 | * @return Page |
||
157 | * |
||
158 | * @see \Brendt\Stitcher\Factory\ParserFactory |
||
159 | * @see \Brendt\Stitcher\Parser\Parser |
||
160 | * @see \Brendt\Stitcher\Site\Page::isParsedVariable() |
||
161 | */ |
||
162 | public function parseVariables(Page $page) { |
||
175 | |||
176 | /** |
||
177 | * @param Page $page |
||
178 | * |
||
179 | * @throws TemplateNotFoundException |
||
180 | */ |
||
181 | public function validate(Page $page) { |
||
192 | |||
193 | /** |
||
194 | * This function will get the parser based on the value. This value is parsed by the parser, or returned if no |
||
195 | * suitable parser was found. |
||
196 | * |
||
197 | * @param $value |
||
198 | * |
||
199 | * @return mixed |
||
200 | * |
||
201 | * @see \Brendt\Stitcher\Factory\ParserFactory |
||
202 | */ |
||
203 | private function getData($value) { |
||
212 | } |
||
213 |
In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:
Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion: