Bitrix-D7
23.9
Загрузка...
Поиск...
Не найдено
elementcountfieldassembler.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
ElementCountFieldAssembler
extends
FieldAssembler
10
{
11
public
function
__construct
()
12
{
13
parent::__construct([
14
'ELEMENT_CNT'
,
15
]);
16
}
17
18
protected
function
prepareRow
(array $row): array
19
{
20
$value =
''
;
21
22
$id = (int)($row[
'data'
][
'ID'
] ?? 0);
23
$rowType = $row[
'data'
][
'ROW_TYPE'
] ??
null
;
24
if
($id > 0 && $rowType ===
RowType::SECTION
)
25
{
26
$count = (int)($row[
'data'
][
'ELEMENT_CNT'
] ?? 0);
27
$allCount = CIBlockSection::GetSectionElementsCount($id, [
'CNT_ALL'
=>
'Y'
]);
28
29
$value =
"{$count} ({$allCount})"
;
30
}
31
32
$row[
'columns'
] ??= [];
33
$row[
'columns'
][
'ELEMENT_CNT'
] = $value;
34
35
return
$row;
36
}
37
}
Bitrix\Iblock\Grid\Row\Assembler\ElementCountFieldAssembler
Definition
elementcountfieldassembler.php:10
Bitrix\Iblock\Grid\Row\Assembler\ElementCountFieldAssembler\__construct
__construct()
Definition
elementcountfieldassembler.php:11
Bitrix\Iblock\Grid\Row\Assembler\ElementCountFieldAssembler\prepareRow
prepareRow(array $row)
Definition
elementcountfieldassembler.php:18
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
elementcountfieldassembler.php
Создано системой
1.10.0