1C-Bitrix 25.700.0
Загрузка...
Поиск...
Не найдено
tabletcolumnsprovider.php
См. документацию.
1<?php
2
4
15
17{
18 public function __construct(
19 private Entity $ormEntity,
20 private ?array $selectFields = null,
21 private ?array $defaultFields = null,
22 private bool $isDefaultShow = true,
23 )
24 {}
25
26 public function prepareColumns(): array
27 {
28 $result = [];
29
30 $isEmptySelectFields = empty($this->selectFields);
31 $isEmptyDefaultFields = empty($this->defaultFields);
32
33 foreach ($this->ormEntity->getFields() as $field)
34 {
35 if (
36 !$isEmptySelectFields
37 && !in_array($field->getName(), $this->selectFields)
38 )
39 {
40 continue;
41 }
42
43 if ($field instanceof ScalarField)
44 {
45 if ($isEmptySelectFields && $field->isPrivate())
46 {
47 continue;
48 }
49
50 $column = $this->createColumnByField($field);
51 $columnId = $column->getId();
52
53 if ($isEmptyDefaultFields)
54 {
55 $column->setDefault(
56 $this->isDefaultShow
57 );
58 }
59 else
60 {
61 $column->setDefault(
62 in_array($columnId, $this->defaultFields)
63 );
64 }
65
66 $result[$columnId] = $column;
67 }
68 }
69
70 return $result;
71 }
72
73 protected function createColumnByField(ScalarField $field): Column
74 {
75 $column = new Column($field->getName());
76 $column
77 ->setName(
78 $field->getTitle() ?: $field->getName()
79 )
80 ->setType(
81 $this->getColumnTypeByField($field)
82 )
83 ->setSort(
84 $column->getId()
85 )
86 ->setEditable(true)
87 ;
88
89 return $column;
90 }
91
92 protected function getColumnTypeByField(ScalarField $field): string
93 {
94 if ($field instanceof FloatField)
95 {
96 return Type::FLOAT;
97 }
98 elseif ($field instanceof IntegerField)
99 {
100 return Type::INT;
101 }
102 elseif ($field instanceof BooleanField)
103 {
104 return Type::CHECKBOX;
105 }
106 elseif (
107 ($field instanceof DateField)
108 || ($field instanceof DatetimeField)
109 )
110 {
111 return Type::DATE;
112 }
113
114 return Type::TEXT;
115 }
116}
__construct(private Entity $ormEntity, private ?array $selectFields=null, private ?array $defaultFields=null, private bool $isDefaultShow=true,)
Определения tabletcolumnsprovider.php:18
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
Определения file_new.php:804
$result
Определения get_property_values.php:14
$selectFields
Определения iblock_catalog_list.php:160
Определения ufield.php:9
Определения color.php:3
Определения collection.php:2
if( $daysToExpire >=0 &&$daysToExpire< 60 elseif)( $daysToExpire< 0)
Определения prolog_main_admin.php:393