1C-Bitrix 25.700.0
Загрузка...
Поиск...
Не найдено
tabletdataprovider.php
См. документацию.
1<?php
2
3namespace Bitrix\Main\Filter;
4
5use Bitrix\Main\ORM\Entity;
6use Bitrix\Main\ORM\Fields\BooleanField;
7use Bitrix\Main\ORM\Fields\DateField;
8use Bitrix\Main\ORM\Fields\DatetimeField;
9use Bitrix\Main\ORM\Fields\FloatField;
10use Bitrix\Main\ORM\Fields\IntegerField;
11use Bitrix\Main\ORM\Fields\ScalarField;
12
14{
15 public function __construct(
16 private Settings $settings,
17 private Entity $entity,
18 private ?array $selectFields = null,
19 private ?array $defaultFields = null,
20 private bool $isDefaultShow = true,
21 )
22 {}
23
24 public function getSettings()
25 {
26 return $this->settings;
27 }
28
29 public function prepareFields(): array
30 {
31 $result = [];
32
33 $isEmptySelectFields = empty($this->selectFields);
34 $isEmptyDefaultFields = empty($this->defaultFields);
35
36 foreach ($this->entity->getFields() as $field)
37 {
38 if (
39 !$isEmptySelectFields
40 && !in_array($field->getName(), $this->selectFields)
41 )
42 {
43 continue;
44 }
45
46 if ($field instanceof ScalarField)
47 {
48 if ($isEmptySelectFields && $field->isPrivate())
49 {
50 continue;
51 }
52
53 $column = $this->createByField($field);
54 $columnId = $column->getId();
55
56 if ($isEmptyDefaultFields)
57 {
58 $column->markAsDefault(
59 $this->isDefaultShow
60 );
61 }
62 else
63 {
64 $column->markAsDefault(
65 in_array($columnId, $this->defaultFields)
66 );
67 }
68
69 $result[$columnId] = $column;
70 }
71 }
72
73 return $result;
74 }
75
76 protected function createByField(ScalarField $field): Field
77 {
78 $result = new Field($this, $field->getName());
79 $result->setName(
80 $field->getTitle() ?: $field->getName()
81 );
82 $result->setType(
83 $this->getTypeByField($field)
84 );
85
86 return $result;
87 }
88
89 protected function getTypeByField(ScalarField $field): string
90 {
91 if (
92 ($field instanceof FloatField)
93 || ($field instanceof IntegerField)
94 )
95 {
96 return 'number';
97 }
98 elseif ($field instanceof BooleanField)
99 {
100 return 'select';
101 }
102 elseif (
103 ($field instanceof DateField)
104 || ($field instanceof DatetimeField)
105 )
106 {
107 return 'date';
108 }
109
110 return 'string';
111 }
112
113 public function prepareFieldData($fieldID)
114 {
115 return null;
116 }
117}
createByField(ScalarField $field)
Определения tabletdataprovider.php:76
__construct(private Settings $settings, private Entity $entity, private ?array $selectFields=null, private ?array $defaultFields=null, private bool $isDefaultShow=true,)
Определения tabletdataprovider.php:15
getTypeByField(ScalarField $field)
Определения tabletdataprovider.php:89
</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
$entity
$selectFields
Определения iblock_catalog_list.php:160
Определения ufield.php:9
$settings
Определения product_settings.php:43
if( $daysToExpire >=0 &&$daysToExpire< 60 elseif)( $daysToExpire< 0)
Определения prolog_main_admin.php:393