Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
productnamefieldassembler.php
1<?php
2
4
11
12Loader::requireModule('iblock');
13
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}
__construct(array $columnIds, BaseBuilder $urlBuilder=null)
static encode($string, $flags=ENT_COMPAT, $doubleEncode=true)