10 private int $iBlockId;
11 private int $elementId;
12 private int $sectionId;
14 private array $additionalSelectFields = [];
15 private bool $isNeedCheckPermissions;
17 private function __construct(
22 $this->iBlockId = $iBlockId;
23 $this->elementId = $elementId;
24 $this->sectionId = $sectionId;
32 $iBlockId = self::validateId($request->iBlockId);
33 if ($iBlockId ===
null || $iBlockId === 0)
38 $elementId = self::validateId($request->elementId);
39 if ($elementId ===
null)
44 $sectionId = self::validateId($request->sectionId);
45 if ($sectionId ===
null)
50 $self =
new self($iBlockId, $elementId, $sectionId);
52 if ($request->additionalSelectFields)
54 $self->setAdditionalSelectFields($request->additionalSelectFields);
57 $self->isNeedCheckPermissions = $request->needCheckPermission;
62 private static function validateId(
int $id): ?int
72 private function setAdditionalSelectFields(array $selectFields): void
74 $allowedFields = [
'FIELDS',
'PROPS',
'IBLOCK_ID',
'IBLOCK_SECTION_ID'];
77 foreach ($selectFields as $fieldId)
79 if (in_array($fieldId, $allowedFields,
true))
85 $this->additionalSelectFields = $fields;
93 return $this->iBlockId;
101 return $this->elementId;
109 return $this->sectionId;
117 return $this->additionalSelectFields;
125 return $this->isNeedCheckPermissions;