Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
fieldassembler.php
1<?php
2
4
6
21abstract class FieldAssembler
22{
28 private array $columnIds;
29 private ?Settings $settings;
30
35 public function __construct(array $columnIds, ?Settings $settings = null)
36 {
37 $this->columnIds = $columnIds;
38 $this->settings = $settings;
39 }
40
44 final public function getColumnIds(): array
45 {
46 return $this->columnIds;
47 }
48
52 final protected function getSettings(): Settings
53 {
54 return $this->settings;
55 }
56
66 public function clone(array $columnIds): FieldAssembler
67 {
68 $clone = clone $this;
69 $clone->columnIds = $columnIds;
70
71 return $clone;
72 }
73
81 protected function prepareColumn($value)
82 {
83 return $value;
84 }
85
96 protected function prepareRow(array $row): array
97 {
98 if (empty($this->getColumnIds()))
99 {
100 return $row;
101 }
102
103 $row['columns'] ??= [];
104
105 foreach ($this->getColumnIds() as $columnId)
106 {
107 $row['columns'][$columnId] = $this->prepareColumn($row['data'][$columnId] ?? null);
108 }
109
110 return $row;
111 }
112
123 public function prepareRows(array $rowList): array
124 {
125 foreach ($rowList as &$row)
126 {
127 $row = $this->prepareRow($row);
128 }
129
130 return $rowList;
131 }
132}
__construct(array $columnIds, ?Settings $settings=null)