Bitrix-D7
23.9
Загрузка...
Поиск...
Не найдено
sectioncountfieldassembler.php
1
<?php
2
3
namespace
Bitrix\Iblock\Grid\Row\Assembler
;
4
5
use
Bitrix\Iblock\Grid\RowType
;
6
use
Bitrix\Main\Grid\Row\FieldAssembler
;
7
use CIBlockSection;
8
9
final
class
SectionCountFieldAssembler
extends
FieldAssembler
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
}
Bitrix\Iblock\Grid\Row\Assembler\SectionCountFieldAssembler
Definition
sectioncountfieldassembler.php:10
Bitrix\Iblock\Grid\Row\Assembler\SectionCountFieldAssembler\__construct
__construct(int $iblockId)
Definition
sectioncountfieldassembler.php:13
Bitrix\Iblock\Grid\Row\Assembler\SectionCountFieldAssembler\prepareRow
prepareRow(array $row)
Definition
sectioncountfieldassembler.php:22
Bitrix\Iblock\Grid\RowType
Definition
rowtype.php:8
Bitrix\Iblock\Grid\RowType\SECTION
const SECTION
Definition
rowtype.php:10
Bitrix\Main\Grid\Row\FieldAssembler
Definition
fieldassembler.php:22
Bitrix\Iblock\Grid\Row\Assembler
Definition
elementcountfieldassembler.php:3
modules
iblock
lib
grid
row
assembler
sectioncountfieldassembler.php
Создано системой
1.10.0