Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
sectioncountfieldassembler.php
1<?php
2
4
7use CIBlockSection;
8
10{
11 private int $iblockId;
12
13 public function __construct(int $iblockId)
14 {
15 parent::__construct([
16 'SECTION_CNT',
17 ]);
18
19 $this->iblockId = $iblockId;
20 }
21
22 protected function prepareRow(array $row): array
23 {
24 $value = '';
25
26 $id = (int)($row['data']['ID'] ?? 0);
27 $rowType = $row['data']['ROW_TYPE'] ?? null;
28 if ($id > 0 && $rowType === RowType::SECTION)
29 {
30 $value = CIBlockSection::GetCount([
31 'IBLOCK_ID' => $this->iblockId,
32 'SECTION_ID' => $id,
33 ]);
34 }
35
36 $row['columns'] ??= [];
37 $row['columns']['SECTION_CNT'] = $value;
38
39 return $row;
40 }
41}