Bitrix-D7
23.9
Загрузка...
Поиск...
Не найдено
DataService.php
1
<?php
2
3
namespace
Bitrix\Lists\Api\Service\ServiceFactory
;
4
5
use
Bitrix\Lists\Api\Data\ServiceFactory\AverageTemplateDurationToGet
;
6
use
Bitrix\Lists\Api\Data\ServiceFactory\ElementToAdd
;
7
use
Bitrix\Lists\Api\Data\ServiceFactory\ElementToGetDetailInfo
;
8
use
Bitrix\Lists\Api\Request\ServiceFactory\AddElementRequest
;
9
use
Bitrix\Lists\Api\Request\ServiceFactory\GetAverageIBlockTemplateDurationRequest
;
10
use
Bitrix\Lists\Api\Request\ServiceFactory\GetElementDetailInfoRequest
;
11
use
Bitrix\Lists\Api\Response\ServiceFactory\AddElementResponse
;
12
use
Bitrix\Lists\Api\Response\ServiceFactory\GetAverageIBlockTemplateDurationResponse
;
13
use
Bitrix\Lists\Api\Response\ServiceFactory\GetElementDetailInfoResponse
;
14
use
Bitrix\Main\ArgumentException
;
15
use
Bitrix\Main\ArgumentOutOfRangeException
;
16
use
Bitrix\Main\Error
;
17
use
Bitrix\Main\Localization\Loc
;
18
19
final
class
DataService
20
{
21
public
function
getElementToGetDetailInfoObject
(
22
GetElementDetailInfoRequest
$request,
23
GetElementDetailInfoResponse
$response
24
): ?
ElementToGetDetailInfo
25
{
26
$elementToGet =
null
;
27
try
28
{
29
$elementToGet =
ElementToGetDetailInfo::createFromRequest
($request);
30
}
31
catch
(
ArgumentOutOfRangeException
$exception)
32
{
33
$parameter = $exception->
getParameter
();
34
if
($parameter ===
'iBlockId'
)
35
{
36
$response->
addError
(self::getWrongIBlockError());
37
}
38
39
if
($parameter ===
'elementId'
)
40
{
41
$response->
addError
(self::getNegativeElementIdError());
42
}
43
44
if
($parameter ===
'sectionId'
)
45
{
46
$response->
addError
(self::getNegativeSectionIdError());
47
}
48
}
49
50
return
$elementToGet;
51
}
52
53
public
function
getElementToAddObject
(
54
AddElementRequest
$request,
55
AddElementResponse
$response
56
): ?
ElementToAdd
57
{
58
$elementToAdd =
null
;
59
try
60
{
61
$elementToAdd =
ElementToAdd::createFromRequest
($request);
62
}
63
catch
(
ArgumentOutOfRangeException
$exception)
64
{
65
$parameter = $exception->
getParameter
();
66
if
($parameter ===
'iBlockId'
)
67
{
68
$response->
addError
(self::getWrongIBlockError());
69
}
70
71
if
($parameter ===
'sectionId'
)
72
{
73
$response->
addError
(self::getNegativeSectionIdError());
74
}
75
76
if
($parameter ===
'createdBy'
)
77
{
78
$response->
addError
(self::getNegativeUserIdError());
79
}
80
}
81
82
return
$elementToAdd;
83
}
84
85
public
function
getAverageTemplateDurationToGetObject
(
86
GetAverageIBlockTemplateDurationRequest
$request,
87
GetAverageIBlockTemplateDurationResponse
$response,
88
): ?
AverageTemplateDurationToGet
89
{
90
$object =
null
;
91
try
92
{
93
$object =
AverageTemplateDurationToGet::createFromRequest
($request);
94
}
95
catch
(
ArgumentOutOfRangeException
$e)
96
{
97
$response->
addError
(self::getWrongIBlockError());
98
}
99
catch
(
ArgumentException
$e)
100
{
101
$response->
addError
(
new
Error
(
'invalid auto execute type'
));
102
}
103
104
return
$object;
105
}
106
107
public
static
function
getWrongIBlockError
():
Error
108
{
109
return
new
Error
(
Loc::getMessage
(
'LISTS_LIB_API_DATA_SERVICE_ERROR_WRONG_IBLOCK'
));
110
}
111
112
private
static
function
getNegativeElementIdError():
Error
113
{
114
return
new
Error
(
Loc::getMessage
(
'LISTS_LIB_API_DATA_SERVICE_ERROR_NEGATIVE_ELEMENT_ID'
));
115
}
116
117
private
static
function
getNegativeSectionIdError():
Error
118
{
119
return
new
Error
(
Loc::getMessage
(
'LISTS_LIB_API_DATA_SERVICE_ERROR_NEGATIVE_SECTION_ID'
));
120
}
121
122
private
static
function
getNegativeUserIdError():
Error
123
{
124
return
new
Error
(
Loc::getMessage
(
'LISTS_LIB_API_DATA_SERVICE_ERROR_NEGATIVE_CREATED_BY_ID'
));
125
}
126
}
Bitrix\Lists\Api\Data\ServiceFactory\AverageTemplateDurationToGet
Definition
AverageTemplateDurationToGet.php:12
Bitrix\Lists\Api\Data\ServiceFactory\AverageTemplateDurationToGet\createFromRequest
static createFromRequest($request)
Definition
AverageTemplateDurationToGet.php:32
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\ElementToGetDetailInfo
Definition
ElementToGetDetailInfo.php:9
Bitrix\Lists\Api\Data\ServiceFactory\ElementToGetDetailInfo\createFromRequest
static createFromRequest(GetElementDetailInfoRequest $request)
Definition
ElementToGetDetailInfo.php:30
Bitrix\Lists\Api\Request\ServiceFactory\AddElementRequest
Definition
AddElementRequest.php:6
Bitrix\Lists\Api\Request\ServiceFactory\GetAverageIBlockTemplateDurationRequest
Definition
GetAverageIBlockTemplateDurationRequest.php:6
Bitrix\Lists\Api\Request\ServiceFactory\GetElementDetailInfoRequest
Definition
GetElementDetailInfoRequest.php:6
Bitrix\Lists\Api\Response\ServiceFactory\AddElementResponse
Definition
AddElementResponse.php:8
Bitrix\Lists\Api\Response\ServiceFactory\GetAverageIBlockTemplateDurationResponse
Definition
GetAverageIBlockTemplateDurationResponse.php:8
Bitrix\Lists\Api\Response\ServiceFactory\GetElementDetailInfoResponse
Definition
GetElementDetailInfoResponse.php:8
Bitrix\Lists\Api\Service\ServiceFactory\DataService
Definition
DataService.php:20
Bitrix\Lists\Api\Service\ServiceFactory\DataService\getWrongIBlockError
static getWrongIBlockError()
Definition
DataService.php:107
Bitrix\Lists\Api\Service\ServiceFactory\DataService\getElementToGetDetailInfoObject
getElementToGetDetailInfoObject(GetElementDetailInfoRequest $request, GetElementDetailInfoResponse $response)
Definition
DataService.php:21
Bitrix\Lists\Api\Service\ServiceFactory\DataService\getElementToAddObject
getElementToAddObject(AddElementRequest $request, AddElementResponse $response)
Definition
DataService.php:53
Bitrix\Lists\Api\Service\ServiceFactory\DataService\getAverageTemplateDurationToGetObject
getAverageTemplateDurationToGetObject(GetAverageIBlockTemplateDurationRequest $request, GetAverageIBlockTemplateDurationResponse $response,)
Definition
DataService.php:85
Bitrix\Main\ArgumentException
Definition
exception.php:34
Bitrix\Main\ArgumentException\getParameter
getParameter()
Definition
exception.php:43
Bitrix\Main\ArgumentOutOfRangeException
Definition
exception.php:67
Bitrix\Main\Error
Definition
error.php:14
Bitrix\Main\Localization\Loc
Definition
loc.php:11
Bitrix\Main\Localization\Loc\getMessage
static getMessage($code, $replace=null, $language=null)
Definition
loc.php:29
Bitrix\Main\Result\addError
addError(Error $error)
Definition
result.php:50
Bitrix\Lists\Api\Service\ServiceFactory
Definition
AccessService.php:3
modules
lists
lib
Api
Service
ServiceFactory
DataService.php
Создано системой
1.10.0