Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
DataService.php
1<?php
2
4
18
19final class DataService
20{
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
89 {
90 $object = null;
91 try
92 {
94 }
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}
static createFromRequest(GetElementDetailInfoRequest $request)
getElementToGetDetailInfoObject(GetElementDetailInfoRequest $request, GetElementDetailInfoResponse $response)
getElementToAddObject(AddElementRequest $request, AddElementResponse $response)
getAverageTemplateDurationToGetObject(GetAverageIBlockTemplateDurationRequest $request, GetAverageIBlockTemplateDurationResponse $response,)
static getMessage($code, $replace=null, $language=null)
Definition loc.php:29
addError(Error $error)
Definition result.php:50