7 private const LIMIT = 5;
10 private array $order = [];
11 private array $navigation = [];
12 private array $selectFields = [
'ID',
'NAME'];
13 private bool $isCheckPermissionsEnabled =
true;
14 private bool $isNeedLoadWorkflowState =
false;
20 int $limit = self::LIMIT,
21 array $additionalSelectFields = [],
24 $this->filter = $filter;
25 $this->setOrder($order);
26 $this->setNavigation($offset, $limit);
27 $this->setAdditionalSelectFields($additionalSelectFields);
30 private function setOrder(array $order): void
32 $allowedFields = [
'ID'];
35 foreach ($order as $field => $value)
38 in_array($field, $allowedFields,
true)
39 && in_array(mb_strtolower((
string)$value), [
'asc',
'desc'],
true)
42 $newOrder[$field] = $value;
46 $this->order = $newOrder;
49 private function setNavigation(
int $offset,
int $limit): void
52 'nPageSize' => $limit >= 0 ? $limit : self::LIMIT,
54 ($limit > 0 && $offset > 0)
55 ? (
int)($offset / $limit) + 1
61 private function setAdditionalSelectFields(array $additionalSelectFields): void
63 $additionalAllowedFields = [
'IBLOCK_ID',
'IBLOCK_SECTION_ID',
'IBLOCK_TYPE_ID',
'FIELDS',
'PROPS'];
66 foreach ($additionalSelectFields as $fieldId)
68 if (in_array($fieldId, $additionalAllowedFields,
true))
74 $this->selectFields = array_merge($this->selectFields, $fields);
84 return $this->filter->getOrmFilter();
94 return $this->navigation;
102 if (!$shouldLoadFields && !$shouldLoadProps)
104 return $this->selectFields;
107 $select = array_filter(
109 static fn($fieldId) => !in_array($fieldId, [
'FIELDS',
'PROPS'],
true)
112 if ($shouldLoadFields && $this->
getFilter()->hasField(
'IBLOCK_ID'))
114 $list = new \CList($this->filter->getFieldValue(
'IBLOCK_ID'));
115 foreach ($list->GetFields() as $fieldId => $property)
117 if ($list->is_field($fieldId))
119 $select[] = $fieldId;
123 $select = array_unique($select);
126 return array_values($select);
131 return in_array(
'PROPS', $this->selectFields,
true);
136 return in_array(
'FIELDS', $this->selectFields,
true);
155 return $this->isCheckPermissionsEnabled;
167 return $this->isNeedLoadWorkflowState;