Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
elementdataprovider.php
1<?php
2
4
9
11{
12 private ElementSettings $settings;
13 private ElementFilterFields $fields;
14
15 public function __construct(ElementSettings $settings)
16 {
17 $this->settings = $settings;
18 $this->fields = ElementFilterFields::createFromElementSettings($settings);
19 }
20
21 public function getSettings(): ElementSettings
22 {
23 return $this->settings;
24 }
25
26 public function prepareFields()
27 {
28 $result = [];
29
30 $fields = $this->fields->getElementFieldsParams();
31 foreach ($fields as $id => $params)
32 {
33 $result[$id] = $this->createField($id, $params);
34 }
35
36 $properties = $this->fields->getElementPropertiesParams();
37 foreach ($properties as $id => $params)
38 {
39 $result[$id] = $this->createField($id, $params);
40 }
41
42 return $result;
43 }
44
45 public function prepareFieldData($fieldID)
46 {
47 if ($fieldID === 'SECTION_ID')
48 {
49 return [
50 'items' => $this->fields->getSectionListItems(),
51 ];
52 }
53 elseif ($fieldID === 'CREATED_BY' || $fieldID === 'MODIFIED_BY')
54 {
55 return $this->getUserEntitySelectorParams($fieldID . '_filter', ['fieldName' => $fieldID]);
56 }
57 elseif ($this->fields->isPropertyId($fieldID))
58 {
59 return $this->fields->getPropertyDescription($fieldID);
60 }
61
62 return null;
63 }
64
65 protected function getFieldName($fieldID)
66 {
67 return Loc::getMessage('IBLOCK_FILTER_ELEMENT_DATAPROVIDER_FIELD_' . $fieldID) ?? $fieldID;
68 }
69
73 public function prepareFilterValue(array $rawFilterValue): array
74 {
75 $rawFilterValue = parent::prepareFilterValue($rawFilterValue);
76
77 if (!empty($rawFilterValue['FIND']))
78 {
79 $rawFilterValue['?NAME'] = $rawFilterValue['FIND'];
80 }
81
82 return $this->fields->prepareFilterValue($rawFilterValue);
83 }
84}
getUserEntitySelectorParams(string $context, array $params)
createField($fieldID, array $params=null)
static getMessage($code, $replace=null, $language=null)
Definition loc.php:29