Bitrix-D7
23.9
Загрузка...
Поиск...
Не найдено
ElementToAdd.php
1
<?php
2
3
namespace
Bitrix\Lists\Api\Data\ServiceFactory
;
4
5
use
Bitrix\Lists\Api\Data\Data
;
6
use
Bitrix\Lists\Api\Request\ServiceFactory\AddElementRequest
;
7
use
Bitrix\Main\ArgumentOutOfRangeException
;
8
9
final
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
}
Bitrix\Lists\Api\Data\Data
Definition
Data.php:6
Bitrix\Lists\Api\Data\Data\validateId
static validateId(int $id)
Definition
Data.php:9
Bitrix\Lists\Api\Data\ServiceFactory\ElementToAdd
Definition
ElementToAdd.php:10
Bitrix\Lists\Api\Data\ServiceFactory\ElementToAdd\createFromRequest
static createFromRequest($request)
Definition
ElementToAdd.php:34
Bitrix\Lists\Api\Data\ServiceFactory\ElementToAdd\getIBlockId
getIBlockId()
Definition
ElementToAdd.php:77
Bitrix\Lists\Api\Data\ServiceFactory\ElementToAdd\getCreatedBy
getCreatedBy()
Definition
ElementToAdd.php:101
Bitrix\Lists\Api\Data\ServiceFactory\ElementToAdd\getSectionId
getSectionId()
Definition
ElementToAdd.php:85
Bitrix\Lists\Api\Data\ServiceFactory\ElementToAdd\getValues
getValues()
Definition
ElementToAdd.php:93
Bitrix\Lists\Api\Request\ServiceFactory\AddElementRequest
Definition
AddElementRequest.php:6
Bitrix\Main\ArgumentOutOfRangeException
Definition
exception.php:67
Bitrix\Lists\Api\Data\ServiceFactory
Definition
AverageTemplateDurationToGet.php:3
modules
lists
lib
Api
Data
ServiceFactory
ElementToAdd.php
Создано системой
1.10.0