1 | <?php |
||
32 | final class AframeDOMDocument extends DOMImplementation |
||
33 | { |
||
34 | |||
35 | /** |
||
36 | * A-Frame DOM Document type |
||
37 | * |
||
38 | * @var \DOMDocumentType |
||
39 | */ |
||
40 | protected $doctypeObj; |
||
41 | |||
42 | /** |
||
43 | * A-Frame DOM Document |
||
44 | * |
||
45 | * @var \DOMDocument |
||
46 | */ |
||
47 | protected $docObj; |
||
48 | |||
49 | /** |
||
50 | * Scene meta tile |
||
51 | * |
||
52 | * @var string $scene_title |
||
53 | */ |
||
54 | protected $scene_title = 'Untitled'; |
||
55 | |||
56 | /** |
||
57 | * Scene meta description |
||
58 | * |
||
59 | * @var string $scene_description |
||
60 | */ |
||
61 | protected $scene_description = ''; |
||
62 | |||
63 | /** |
||
64 | * CDN Of aframe.js |
||
65 | * |
||
66 | * @var string |
||
67 | */ |
||
68 | protected $aframe_cdn; |
||
69 | |||
70 | /** |
||
71 | * Whether to use CDN |
||
72 | * |
||
73 | * @var bool $use_cdn |
||
74 | */ |
||
75 | protected $use_cdn = false; |
||
76 | |||
77 | /** |
||
78 | * <head> |
||
79 | * |
||
80 | * @var \DOMElement $head |
||
81 | */ |
||
82 | protected $head; |
||
83 | |||
84 | /** |
||
85 | * <body> |
||
86 | * |
||
87 | * @var \DOMElement $body |
||
88 | */ |
||
89 | protected $body; |
||
90 | |||
91 | /** |
||
92 | * <a-scene> |
||
93 | * |
||
94 | * @var \DOMElement $scene |
||
95 | */ |
||
96 | protected $scene; |
||
97 | |||
98 | /** |
||
99 | * Nicely formats output with indentation and extra space. |
||
100 | * |
||
101 | * @var bool |
||
102 | */ |
||
103 | public $formatOutput = true; |
||
104 | |||
105 | /** |
||
106 | * A-Frame DOM |
||
107 | * |
||
108 | * @param Config $config |
||
109 | * @return void |
||
|
|||
110 | */ |
||
111 | 59 | public function __construct(Config $config) |
|
126 | |||
127 | /** |
||
128 | * Load aframe.in.js from CDN |
||
129 | * |
||
130 | * @return void |
||
131 | */ |
||
132 | 2 | public function useCDN() |
|
136 | |||
137 | /** |
||
138 | * Set CDN for aframe.js or min.js |
||
139 | * |
||
140 | * @param string $cdn |
||
141 | * @return void |
||
142 | */ |
||
143 | 59 | public function setCDN(string $cdn) |
|
147 | |||
148 | /** |
||
149 | * Render scene this DOM Object is attached to |
||
150 | * |
||
151 | * @param bool $only_scene |
||
152 | * @return string |
||
153 | */ |
||
154 | 3 | public function render(): string |
|
166 | |||
167 | /** |
||
168 | * Set Scene meta title |
||
169 | * |
||
170 | * @param string $title |
||
171 | */ |
||
172 | 2 | public function setTitle(string $title) |
|
176 | |||
177 | /** |
||
178 | * Set Scene meta description |
||
179 | * |
||
180 | * @param string $title |
||
181 | */ |
||
182 | 2 | public function setDescription(string $description) |
|
186 | |||
187 | /** |
||
188 | * Append entities |
||
189 | * |
||
190 | * @param array $entities |
||
191 | * @return void |
||
192 | */ |
||
193 | 3 | public function appendEntities(array $entities) |
|
201 | |||
202 | /** |
||
203 | * Add entity |
||
204 | * |
||
205 | * @param Entity $entity |
||
206 | * @return void |
||
207 | */ |
||
208 | 1 | public function appendEntity(Entity $entity) |
|
212 | |||
213 | /** |
||
214 | * Get HTML of Scene only |
||
215 | * |
||
216 | * @return string |
||
217 | */ |
||
218 | 1 | public function renderSceneOnly() |
|
225 | |||
226 | /** |
||
227 | * Prepeare head |
||
228 | * |
||
229 | * @return void |
||
230 | */ |
||
231 | 3 | protected function renderHead() |
|
256 | |||
257 | /** |
||
258 | * If requested by user use aframe CDN |
||
259 | * |
||
260 | * @return void |
||
261 | */ |
||
262 | 3 | protected function appendCDN() |
|
270 | |||
271 | /** |
||
272 | * Prepare body |
||
273 | * |
||
274 | * @return void |
||
275 | */ |
||
276 | 3 | protected function renderBody() |
|
280 | |||
281 | /** |
||
282 | * Create meta tags |
||
283 | * |
||
284 | * @param array $attr |
||
285 | */ |
||
286 | 3 | protected function appendMetaTag(array $attr) |
|
293 | |||
294 | /** |
||
295 | * Create title tag |
||
296 | * |
||
297 | * @return void |
||
298 | */ |
||
299 | 3 | protected function appendTitle() |
|
304 | |||
305 | /** |
||
306 | * Creates an empty DOMDocumentType object |
||
307 | * |
||
308 | * @param string $doctype |
||
309 | * @return void |
||
310 | */ |
||
311 | 59 | protected function createDocType(string $doctype) |
|
315 | |||
316 | /** |
||
317 | * Creates a DOMDocument object of the specified type with its document element |
||
318 | * |
||
319 | * @return void |
||
320 | */ |
||
321 | 59 | protected function createAframeDocument() |
|
325 | |||
326 | /** |
||
327 | * Create <head> element node |
||
328 | * |
||
329 | * @return void |
||
330 | */ |
||
331 | 59 | protected function createHead() |
|
335 | |||
336 | /** |
||
337 | * Create <body> element node |
||
338 | * |
||
339 | * @return void |
||
340 | */ |
||
341 | 59 | protected function createBody() |
|
345 | |||
346 | /** |
||
347 | * Create <a-scene> element node |
||
348 | * |
||
349 | * @return void |
||
350 | */ |
||
351 | 59 | protected function createScene() |
|
355 | } |
||
356 |
Adding a
@return
annotation to a constructor is not recommended, since a constructor does not have a meaningful return value.Please refer to the PHP core documentation on constructors.