@@ 8-41 (lines=34) @@ | ||
5 | use rtens\domin\delivery\web\Element; |
|
6 | use rtens\domin\delivery\web\renderers\dashboard\DashboardItem; |
|
7 | ||
8 | class Dashboard implements DashboardItem { |
|
9 | ||
10 | /** @var array|Row[] */ |
|
11 | private $rows; |
|
12 | ||
13 | /** |
|
14 | * @param array|Row[] $rows |
|
15 | */ |
|
16 | public function __construct(array $rows) { |
|
17 | $this->rows = $rows; |
|
18 | } |
|
19 | ||
20 | /** |
|
21 | * @param RendererRegistry $renderers |
|
22 | * @return Element |
|
23 | */ |
|
24 | public function render(RendererRegistry $renderers) { |
|
25 | return new Element('div', [], array_map(function (Row $row) use ($renderers) { |
|
26 | return $row->render($renderers); |
|
27 | }, $this->rows)); |
|
28 | } |
|
29 | ||
30 | /** |
|
31 | * @param RendererRegistry $renderers |
|
32 | * @return \rtens\domin\delivery\web\Element[] |
|
33 | */ |
|
34 | public function headElements(RendererRegistry $renderers) { |
|
35 | $elements = []; |
|
36 | foreach ($this->rows as $row) { |
|
37 | $elements = array_merge($elements, $row->headElements($renderers)); |
|
38 | } |
|
39 | return $elements; |
|
40 | } |
|
41 | } |
@@ 8-41 (lines=34) @@ | ||
5 | use rtens\domin\delivery\web\Element; |
|
6 | use rtens\domin\delivery\web\renderers\dashboard\DashboardItem; |
|
7 | ||
8 | class Row implements DashboardItem { |
|
9 | ||
10 | /** @var array|Column[] */ |
|
11 | private $columns; |
|
12 | ||
13 | /** |
|
14 | * @param array|Column[] $columns |
|
15 | */ |
|
16 | public function __construct(array $columns) { |
|
17 | $this->columns = $columns; |
|
18 | } |
|
19 | ||
20 | /** |
|
21 | * @param RendererRegistry $renderers |
|
22 | * @return Element |
|
23 | */ |
|
24 | public function render(RendererRegistry $renderers) { |
|
25 | return new Element('div', ['class' => 'row'], array_map(function (Column $column) use ($renderers) { |
|
26 | return $column->render($renderers); |
|
27 | }, $this->columns)); |
|
28 | } |
|
29 | ||
30 | /** |
|
31 | * @param RendererRegistry $renderers |
|
32 | * @return \rtens\domin\delivery\web\Element[] |
|
33 | */ |
|
34 | public function headElements(RendererRegistry $renderers) { |
|
35 | $elements = []; |
|
36 | foreach ($this->columns as $column) { |
|
37 | $elements = array_merge($elements, $column->headElements($renderers)); |
|
38 | } |
|
39 | return $elements; |
|
40 | } |
|
41 | } |