1C-Bitrix 25.700.0
Загрузка...
Поиск...
Не найдено
DataService.php
См. документацию.
1<?php
2
3namespace Bitrix\Lists\Api\Service\ServiceFactory;
4
5use Bitrix\Lists\Api\Data\ServiceFactory\AverageTemplateDurationToGet;
6use Bitrix\Lists\Api\Data\ServiceFactory\ElementToAdd;
7use Bitrix\Lists\Api\Data\ServiceFactory\ElementToGetDetailInfo;
8use Bitrix\Lists\Api\Data\ServiceFactory\ElementToUpdate;
9use Bitrix\Lists\Api\Request\ServiceFactory\AddElementRequest;
10use Bitrix\Lists\Api\Request\ServiceFactory\GetAverageIBlockTemplateDurationRequest;
11use Bitrix\Lists\Api\Request\ServiceFactory\GetElementDetailInfoRequest;
12use Bitrix\Lists\Api\Request\ServiceFactory\UpdateElementRequest;
13use Bitrix\Lists\Api\Response\ServiceFactory\AddElementResponse;
14use Bitrix\Lists\Api\Response\ServiceFactory\GetAverageIBlockTemplateDurationResponse;
15use Bitrix\Lists\Api\Response\ServiceFactory\GetElementDetailInfoResponse;
16use Bitrix\Lists\Api\Response\ServiceFactory\UpdateElementResponse;
17use Bitrix\Main\ArgumentException;
18use Bitrix\Main\ArgumentOutOfRangeException;
19use Bitrix\Main\Error;
20use Bitrix\Main\Localization\Loc;
21
22final class DataService
23{
28 {
29 $elementToGet = null;
30 try
31 {
33 }
34 catch (ArgumentOutOfRangeException $exception)
35 {
36 $parameter = $exception->getParameter();
37 if ($parameter === 'iBlockId')
38 {
39 $response->addError(self::getWrongIBlockError());
40 }
41
42 if ($parameter === 'elementId')
43 {
44 $response->addError(self::getNegativeElementIdError());
45 }
46
47 if ($parameter === 'sectionId')
48 {
49 $response->addError(self::getNegativeSectionIdError());
50 }
51 }
52
53 return $elementToGet;
54 }
55
56 public function getElementToAddObject(
59 ): ?ElementToAdd
60 {
61 $elementToAdd = null;
62 try
63 {
65 }
66 catch (ArgumentOutOfRangeException $exception)
67 {
68 $parameter = $exception->getParameter();
69 if ($parameter === 'iBlockId')
70 {
71 $response->addError(self::getWrongIBlockError());
72 }
73
74 if ($parameter === 'sectionId')
75 {
76 $response->addError(self::getNegativeSectionIdError());
77 }
78
79 if ($parameter === 'createdBy')
80 {
81 $response->addError(self::getNegativeUserIdError());
82 }
83 }
84
85 return $elementToAdd;
86 }
87
88 public function getElementToUpdateObject(
92 {
93 $elementToUpdate = null;
94 try
95 {
97 }
98 catch (ArgumentOutOfRangeException $exception)
99 {
100 $parameter = $exception->getParameter();
101 if ($parameter === 'elementId')
102 {
103 $response->addError(self::getNegativeElementIdError());
104 }
105
106 if ($parameter === 'iBlockId')
107 {
108 $response->addError(self::getWrongIBlockError());
109 }
110
111 if ($parameter === 'sectionId')
112 {
113 $response->addError(self::getNegativeSectionIdError());
114 }
115
116 if ($parameter === 'modifiedBy')
117 {
118 $response->addError(self::getNegativeUserIdError());
119 }
120 }
121
122 return $elementToUpdate;
123 }
124
129 {
130 $object = null;
131 try
132 {
134 }
136 {
137 $response->addError(self::getWrongIBlockError());
138 }
139 catch (ArgumentException $e)
140 {
141 $response->addError(new Error('invalid auto execute type'));
142 }
143
144 return $object;
145 }
146
147 public static function getWrongIBlockError(): Error
148 {
149 return new Error(Loc::getMessage('LISTS_LIB_API_DATA_SERVICE_ERROR_WRONG_IBLOCK'));
150 }
151
152 private static function getNegativeElementIdError(): Error
153 {
154 return new Error(Loc::getMessage('LISTS_LIB_API_DATA_SERVICE_ERROR_NEGATIVE_ELEMENT_ID'));
155 }
156
157 private static function getNegativeSectionIdError(): Error
158 {
159 return new Error(Loc::getMessage('LISTS_LIB_API_DATA_SERVICE_ERROR_NEGATIVE_SECTION_ID'));
160 }
161
162 private static function getNegativeUserIdError(): Error
163 {
164 return new Error(Loc::getMessage('LISTS_LIB_API_DATA_SERVICE_ERROR_NEGATIVE_CREATED_BY_ID'));
165 }
166}
if(!Loader::includeModule('catalog')) if(!AccessController::getCurrent() ->check(ActionDictionary::ACTION_PRICE_EDIT)) if(!check_bitrix_sessid()) $request
Определения catalog_reindex.php:36
static createFromRequest(GetElementDetailInfoRequest $request)
Определения ElementToGetDetailInfo.php:30
getElementToGetDetailInfoObject(GetElementDetailInfoRequest $request, GetElementDetailInfoResponse $response)
Определения DataService.php:24
getElementToAddObject(AddElementRequest $request, AddElementResponse $response)
Определения DataService.php:56
getElementToUpdateObject(UpdateElementRequest $request, UpdateElementResponse $response)
Определения DataService.php:88
getAverageTemplateDurationToGetObject(GetAverageIBlockTemplateDurationRequest $request, GetAverageIBlockTemplateDurationResponse $response,)
Определения DataService.php:125
Определения error.php:15
$response
Определения result.php:21