Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
0.00% |
0 / 21 |
|
0.00% |
0 / 8 |
CRAP | |
0.00% |
0 / 1 |
HtmlRenderingInformation | |
0.00% |
0 / 21 |
|
0.00% |
0 / 8 |
72 | |
0.00% |
0 / 1 |
__construct | |
0.00% |
0 / 4 |
|
0.00% |
0 / 1 |
2 | |||
getHtml | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
getModules | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
getModuleStyles | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
getHeadItems | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
serializeForApiResult | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
fromArray | |
0.00% |
0 / 6 |
|
0.00% |
0 / 1 |
2 | |||
toArray | |
0.00% |
0 / 6 |
|
0.00% |
0 / 1 |
2 |
1 | <?php |
2 | |
3 | namespace Flow\Model; |
4 | |
5 | use ApiSerializable; |
6 | |
7 | /** |
8 | * Represents an HTML snippet, and associated information needed to render it |
9 | */ |
10 | class HtmlRenderingInformation implements ApiSerializable { |
11 | /** |
12 | * Main HTML |
13 | * |
14 | * @var string |
15 | */ |
16 | protected $html; |
17 | |
18 | /** |
19 | * Array of ResourceLoader module names |
20 | * |
21 | * @var array |
22 | */ |
23 | protected $modules; |
24 | |
25 | /** |
26 | * Array of ResourceLoader module names to be included as style-only modules. |
27 | * |
28 | * @var array |
29 | */ |
30 | protected $moduleStyles; |
31 | |
32 | /** |
33 | * Array of head items (see OutputPage::addHeadItems), as an array |
34 | * of raw HTML strings. |
35 | * |
36 | * @var array |
37 | */ |
38 | protected $headItems; |
39 | |
40 | /** |
41 | * @param string $html |
42 | * @param array $modules |
43 | * @param array $moduleStyles |
44 | * @param array $headItems |
45 | */ |
46 | public function __construct( $html, array $modules, array $moduleStyles, array $headItems ) { |
47 | $this->html = $html; |
48 | $this->modules = $modules; |
49 | $this->moduleStyles = $moduleStyles; |
50 | $this->headItems = $headItems; |
51 | } |
52 | |
53 | public function getHtml() { |
54 | return $this->html; |
55 | } |
56 | |
57 | public function getModules() { |
58 | return $this->modules; |
59 | } |
60 | |
61 | public function getModuleStyles() { |
62 | return $this->moduleStyles; |
63 | } |
64 | |
65 | public function getHeadItems() { |
66 | return $this->headItems; |
67 | } |
68 | |
69 | /** |
70 | * @return array |
71 | */ |
72 | public function serializeForApiResult() { |
73 | return $this->toArray(); |
74 | } |
75 | |
76 | /** |
77 | * Constructs the object from an associative array |
78 | * |
79 | * @param array $info With following keys: |
80 | * - string $info['html'] |
81 | * - array (optional) $info['modules'] |
82 | * - array (optional) $info['modulestyles'] |
83 | * - array (optional) $info['headitems'] |
84 | * @return HtmlRenderingInformation |
85 | */ |
86 | public static function fromArray( array $info ) { |
87 | return new HtmlRenderingInformation( |
88 | $info['html'], |
89 | $info['modules'] ?? [], |
90 | $info['modulestyles'] ?? [], |
91 | $info['headitems'] ?? [] |
92 | ); |
93 | } |
94 | |
95 | public function toArray() { |
96 | return [ |
97 | 'html' => $this->html, |
98 | 'modules' => $this->modules, |
99 | 'modulestyles' => $this->moduleStyles, |
100 | 'headitems' => $this->headItems, |
101 | ]; |
102 | } |
103 | } |