Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
multiplefieldassembler.php
1<?php
2
4
9
11{
12 private int $iblockId;
13
14 public function __construct(int $iblockId, array $excludeColumnsIds)
15 {
16 $this->iblockId = $iblockId;
17
18 parent::__construct(
19 $this->getPropertyColumnsIds($excludeColumnsIds)
20 );
21 }
22
23 private function getPropertyColumnsIds(array $excludeColumnsIds): array
24 {
25 $result = [];
26
28 'select' => [
29 'ID',
30 ],
31 'filter' => [
32 '=IBLOCK_ID' => $this->iblockId,
33 '=MULTIPLE' => 'Y',
34 'USER_TYPE' => null,
35 ],
36 ]);
37 foreach ($rows as $row)
38 {
39 $columnId = ElementPropertyProvider::getColumnIdByPropertyId((int)$row['ID']);
40 if (!in_array($columnId, $excludeColumnsIds, true))
41 {
42 $result[] = $columnId;
43 }
44 }
45
46 return $result;
47 }
48
49 protected function prepareRow(array $row): array
50 {
51 $columnIds = $this->getColumnIds();
52 if (empty($columnIds))
53 {
54 return $row;
55 }
56
57 $row['columns'] ??= [];
58
59 foreach ($columnIds as $columnId)
60 {
61 $value = $this->getFlatColumnValues($row['data'][$columnId] ?? null);
62 if (is_array($value))
63 {
64 $value = join(' / ', $value);
65 }
66 $value = Main\Text\HtmlFilter::encode((string)$value);
67
68 $row['columns'][$columnId] ??= $value;
69 $row['data']['~' . $columnId] ??= $value;
70 }
71
72 return $row;
73 }
74
75 private static function getFlatColumnValues(mixed $rawValues)
76 {
77 if (!is_array($rawValues))
78 {
79 return null;
80 }
81 if (array_key_exists('VALUE', $rawValues))
82 {
83 return $rawValues['VALUE'];
84 }
85 else
86 {
87 $result = [];
88 foreach ($rawValues as $row)
89 {
90 if (is_array($row) && array_key_exists('VALUE', $row))
91 {
92 $result[] = $row['VALUE'];
93 }
94 }
95
96 return $result;
97 }
98 }
99}
static getList(array $parameters=array())