Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
rowassembler.php
1<?php
2
4
32abstract class RowAssembler
33{
37 private array $fieldAssemblers;
41 private array $visibleColumnIds;
42
46 public function __construct(array $visibleColumnIds)
47 {
48 $this->visibleColumnIds = $visibleColumnIds;
49 }
50
54 abstract protected function prepareFieldAssemblers(): array;
55
59 final protected function getVisibleColumnIds(): array
60 {
61 return $this->visibleColumnIds;
62 }
63
67 private function getAssemblers(): array
68 {
69 if (!isset($this->fieldAssemblers))
70 {
71 $this->fieldAssemblers = [];
72
73 foreach ($this->prepareFieldAssemblers() as $assembler)
74 {
75 $this->fieldAssemblers[] = $assembler;
76 }
77 }
78
79 return $this->fieldAssemblers;
80 }
81
85 private function getFilteredAssemblers(): array
86 {
87 $result = [];
88
89 foreach ($this->getAssemblers() as $fieldAssembler)
90 {
91 $assemblerColumnsIds = $fieldAssembler->getColumnIds();
92 $columnsIds = array_intersect($assemblerColumnsIds, $this->getVisibleColumnIds());
93
94 if (!empty($columnsIds))
95 {
96 if (count($assemblerColumnsIds) !== count($columnsIds))
97 {
98 $result[] = $fieldAssembler->clone($columnsIds);
99 }
100 else
101 {
102 $result[] = $fieldAssembler;
103 }
104 }
105 }
106
107 return $result;
108 }
109
117 public function prepareRows(array $rowsList): array
118 {
119 foreach ($this->getFilteredAssemblers() as $fieldAssembler)
120 {
121 $rowsList = $fieldAssembler->prepareRows($rowsList);
122 }
123
124 return $rowsList;
125 }
126}
__construct(array $visibleColumnIds)