Bitrix-D7
23.9
Загрузка...
Поиск...
Не найдено
productnamefieldassembler.php
1
<?php
2
3
namespace
Bitrix\Catalog\Grid\Row\Assembler
;
4
5
use
Bitrix\Iblock\Grid\RowType
;
6
use
Bitrix\Iblock\Url\AdminPage\BaseBuilder
;
7
use
Bitrix\Main\Grid\Row\FieldAssembler
;
8
use
Bitrix\Main\Loader
;
9
use
Bitrix\Main\Text\HtmlFilter
;
10
use
Bitrix\Main\Web\Uri
;
11
12
Loader::requireModule(
'iblock'
);
13
14
final
class
ProductNameFieldAssembler
extends
FieldAssembler
15
{
16
private
?
BaseBuilder
$urlBuilder;
17
18
public
function
__construct
(array $columnIds,
BaseBuilder
$urlBuilder =
null
)
19
{
20
parent::__construct($columnIds);
21
22
$this->urlBuilder = $urlBuilder;
23
}
24
25
protected
function
prepareRow
(array $row): array
26
{
27
$rowType = $row[
'data'
][
'ROW_TYPE'
] ??
null
;
28
if
($rowType !== RowType::ELEMENT)
29
{
30
return
$row;
31
}
32
33
$elementId = (int)($row[
'data'
][
'ID'
] ?? 0);
34
$elementName = (string)($row[
'data'
][
'NAME'
] ??
''
);
35
if
($elementId > 0 && !empty($elementName))
36
{
37
$name =
HtmlFilter::encode
($elementName);
38
39
if
(isset($this->urlBuilder))
40
{
41
$link =
new
Uri
(
42
$this->urlBuilder->getElementDetailUrl($elementId)
43
);
44
45
$columnValue =
46
'<a href="'
.
HtmlFilter::encode
($link->toAbsolute()) .
'">'
47
. $name
48
.
'</a>'
49
;
50
}
51
else
52
{
53
$columnValue =
54
'<div>'
55
. $name
56
.
'</div>'
57
;
58
}
59
60
$row[
'columns'
] ??= [];
61
foreach
($this->
getColumnIds
() as $columnId)
62
{
63
$row[
'columns'
][$columnId] = $columnValue;
64
}
65
}
66
67
return
$row;
68
}
69
}
Bitrix\Catalog\Grid\Row\Assembler\ProductNameFieldAssembler
Definition
productnamefieldassembler.php:15
Bitrix\Catalog\Grid\Row\Assembler\ProductNameFieldAssembler\__construct
__construct(array $columnIds, BaseBuilder $urlBuilder=null)
Definition
productnamefieldassembler.php:18
Bitrix\Catalog\Grid\Row\Assembler\ProductNameFieldAssembler\prepareRow
prepareRow(array $row)
Definition
productnamefieldassembler.php:25
Bitrix\Iblock\Grid\RowType
Definition
rowtype.php:8
Bitrix\Iblock\Url\AdminPage\BaseBuilder
Definition
basebuilder.php:8
Bitrix\Main\Grid\Row\FieldAssembler
Definition
fieldassembler.php:22
Bitrix\Main\Grid\Row\FieldAssembler\getColumnIds
getColumnIds()
Definition
fieldassembler.php:44
Bitrix\Main\Loader
Definition
loader.php:12
Bitrix\Main\Text\HtmlFilter
Definition
htmlfilter.php:11
Bitrix\Main\Text\HtmlFilter\encode
static encode($string, $flags=ENT_COMPAT, $doubleEncode=true)
Definition
htmlfilter.php:12
Bitrix\Main\Web\Uri
Definition
uri.php:17
Bitrix\Catalog\Grid\Row\Assembler
modules
catalog
lib
grid
row
assembler
productnamefieldassembler.php
Создано системой
1.10.0