@@ -24,36 +24,21 @@ abstract class BaseTemplateRenderer
24
24
* @var int
25
25
*/
26
26
public int $ sorting ;
27
+
27
28
/**
28
- * CSS Files to load.
29
- *
30
- * @var string[]
31
- */
32
- public array $ css = [];
33
- /**
34
- * JS Files to load.
35
- *
36
- * @var string[]
37
- */
38
- public array $ js = [];
39
- /**
40
- * The image to use as a logo.
41
- *
42
- * @var string|null
43
- */
44
- protected ?string $ image = null ;
45
- /**
46
- * The template file to load.
29
+ * JSON representation of an API Blueprint.
47
30
*
48
- * @var string
31
+ * @var object
49
32
*/
50
- protected string $ template ;
33
+ protected object $ object ;
34
+
51
35
/**
52
36
* The base data of the API.
53
37
*
54
38
* @var array<string, mixed>
55
39
*/
56
- protected array $ base_data ;
40
+ protected array $ base_data = [];
41
+
57
42
/**
58
43
* JSON object of the API blueprint.
59
44
*
@@ -66,4 +51,39 @@ abstract class BaseTemplateRenderer
66
51
* @var ObjectStructureElement[]
67
52
*/
68
53
protected array $ base_structures = [];
54
+
55
+ /**
56
+ * Parse base data
57
+ *
58
+ * @param object $object
59
+ */
60
+ protected function parse_base_data (object $ object ): void
61
+ {
62
+ //Prepare base data
63
+ if (!is_array ($ object ->content [0 ]->content )) {
64
+ return ;
65
+ }
66
+
67
+ $ this ->base_data ['TITLE ' ] = $ object ->content [0 ]->meta ->title ->content ?? '' ;
68
+
69
+ foreach ($ object ->content [0 ]->attributes ->metadata ->content as $ meta ) {
70
+ $ this ->base_data [$ meta ->content ->key ->content ] = $ meta ->content ->value ->content ;
71
+ }
72
+
73
+ foreach ($ object ->content [0 ]->content as $ value ) {
74
+ if ($ value ->element === 'copy ' ) {
75
+ $ this ->base_data ['DESC ' ] = $ value ->content ;
76
+ continue ;
77
+ }
78
+
79
+ $ cat = new Category ();
80
+ $ cat = $ cat ->parse ($ value );
81
+
82
+ if (($ value ->meta ->classes ->content [0 ]->content ?? null ) === 'dataStructures ' ) {
83
+ $ this ->base_structures = array_merge ($ this ->base_structures , $ cat ->structures );
84
+ } else {
85
+ $ this ->categories [] = $ cat ;
86
+ }
87
+ }
88
+ }
69
89
}
0 commit comments