1C-Bitrix 25.700.0
Загрузка...
Поиск...
Не найдено
ElementToAdd.php
См. документацию.
1<?php
2
3namespace Bitrix\Lists\Api\Data\ServiceFactory;
4
5use Bitrix\Lists\Api\Data\Data;
6use Bitrix\Lists\Api\Request\ServiceFactory\AddElementRequest;
7use Bitrix\Main\ArgumentOutOfRangeException;
8
9final class ElementToAdd extends Data
10{
11 private int $iBlockId;
12 private int $sectionId;
13 private array $values;
14 private int $createdBy;
15
16 private function __construct(
17 int $iBlockId,
18 int $sectionId,
19 array $values,
20 int $createdBy,
21 )
22 {
23 $this->iBlockId = $iBlockId;
24 $this->sectionId = $sectionId;
25 $this->values = $values;
26 $this->createdBy = $createdBy;
27 }
28
34 public static function createFromRequest($request): self
35 {
36 $iBlockId = self::validateId($request->iBlockId);
37 if ($iBlockId === null || $iBlockId === 0)
38 {
39 throw new ArgumentOutOfRangeException('iBlockId', 1, null);
40 }
41
42 $sectionId = self::validateId($request->sectionId);
43 if ($sectionId === null)
44 {
45 throw new ArgumentOutOfRangeException('sectionId', 0, null);
46 }
47
48 $createdBy = self::validateId($request->createdByUserId);
49 if ($createdBy === null || $createdBy === 0)
50 {
51 throw new ArgumentOutOfRangeException('createdBy', 1, null);
52 }
53
54 $values = self::validateValues($request->values, $iBlockId, $sectionId);
55
56 return new self($iBlockId, $sectionId, $values, $createdBy);
57 }
58
65 private static function validateValues(array $values, int $iBlockId, int $sectionId): array
66 {
67 unset($values['ID']);
68 $values['IBLOCK_ID'] = $iBlockId;
69 $values['IBLOCK_SECTION_ID'] = $sectionId;
70
71 return $values;
72 }
73
77 public function getIBlockId(): int
78 {
79 return $this->iBlockId;
80 }
81
85 public function getSectionId(): int
86 {
87 return $this->sectionId;
88 }
89
93 public function getValues(): array
94 {
95 return $this->values;
96 }
97
101 public function getCreatedBy(): int
102 {
103 return $this->createdBy;
104 }
105}
if(!Loader::includeModule('catalog')) if(!AccessController::getCurrent() ->check(ActionDictionary::ACTION_PRICE_EDIT)) if(!check_bitrix_sessid()) $request
Определения catalog_reindex.php:36
static validateId(int $id)
Определения Data.php:9
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
Определения file_new.php:804
$iBlockId
Определения iblock_subelement_generator.php:45