Bitrix-D7
23.9
Загрузка...
Поиск...
Не найдено
statisticprovider.php
1
<?php
2
3
4
namespace
Bitrix\Sale\Exchange\Integration\Controller
;
5
6
7
use
Bitrix\Main\Engine\Action
;
8
use
Bitrix\Main\Error
;
9
use
Bitrix\Rest\Integration\Controller\Base
;
10
use
Bitrix\Sale\Rest\View\SaleViewManager
;
11
use
Bitrix\Sale\Exchange\Integration\Entity\B24IntegrationStatProviderTable
;
12
use
Bitrix\Sale\Result
;
13
use
Bitrix\Main\Engine\Response\DataType\Page
;
14
use
Bitrix\Main\UI\PageNavigation
;
15
16
class
StatisticProvider
extends
Base
17
{
18
//region Actions
19
public
function
getFieldsAction
()
20
{
21
$view = $this->
getViewManager
()
22
->getView($this);
23
24
return
[
'STATISTIC_PROVIDER'
=>$view->prepareFieldInfos(
25
$view->getFields()
26
)];
27
}
28
40
public
function
listAction
($select = [], $filter = [], $order = [],
PageNavigation
$pageNavigation =
null
):
Page
41
{
42
return
new
Page
(
'STATISTIC_PROVIDERS'
,
43
$this->
getList
($select, $filter, $order, $pageNavigation),
44
$this->
count
($filter)
45
);
46
}
47
56
public
function
getAction
($id)
57
{
58
$r = $this->
exists
($id);
59
if
($r->isSuccess())
60
{
61
return
[
'STATISTIC_PROVIDER'
=>$this->
get
($id)];
62
}
63
else
64
{
65
$this->
addErrors
($r->getErrors());
66
return
null
;
67
}
68
}
69
78
public
function
addAction
(array $fields)
79
{
80
$r = $this->
existsByFilter
([
'XML_ID'
=>$fields[
'XML_ID'
]]);
81
82
if
($r->isSuccess() ===
false
)
83
{
84
$r = parent::add($fields);
85
if
($r->isSuccess())
86
{
87
return
[
'STATISTIC_PROVIDER'
=>$this->
get
($r->getPrimary())];
88
}
89
}
90
else
91
{
92
$r->addError(
new
Error
(
'Duplicate entry for key [xmlId]'
));
93
}
94
95
96
$this->
addErrors
($r->getErrors());
97
return
null
;
98
}
99
109
public
function
updateAction
($id, array $fields)
110
{
111
$r = $this->
existsByFilter
([
112
'XML_ID'
=>$fields[
'XML_ID'
],
113
'!ID'
=>$id
114
]);
115
if
($r->isSuccess() ===
false
)
116
{
117
$r = parent::update($id, $fields);
118
if
($r->isSuccess())
119
{
120
return
[
'STATISTIC_PROVIDER'
=>$this->
get
($id)];
121
}
122
}
123
else
124
{
125
$r->addError(
new
Error
(
'Duplicate entry for key [xmlId]'
));
126
}
127
128
129
$this->
addErrors
($r->getErrors());
130
return
null
;
131
}
132
141
public
function
deleteAction
($id)
142
{
143
$r = parent::delete($id);
144
if
($r->isSuccess())
145
{
146
return
true
;
147
}
148
else
149
{
150
$this->
addErrors
($r->getErrors());
151
return
null
;
152
}
153
}
154
//endregion
155
156
protected
function
createViewManager
(
Action
$action)
157
{
158
return
new
SaleViewManager
($action);
159
}
160
161
protected
function
getEntityTable
()
162
{
163
return
new
B24IntegrationStatProviderTable
();
164
}
165
166
protected
function
checkReadPermissionEntity
()
167
{
168
return
new
Result
();
169
}
170
171
protected
function
checkCreatePermissionEntity
()
172
{
173
return
new
Result
();
174
}
175
176
protected
function
checkUpdatePermissionEntity
()
177
{
178
return
new
Result
();
179
}
180
181
protected
function
checkDeletePermissionEntity
()
182
{
183
return
new
Result
();
184
}
185
}
Bitrix\Main\DB\Result
Definition
result.php:19
Bitrix\Main\Engine\Action
Definition
action.php:17
Bitrix\Main\Engine\Controller\addErrors
addErrors(array $errors)
Definition
controller.php:1064
Bitrix\Main\Engine\Response\DataType\Page
Definition
page.php:8
Bitrix\Main\Error
Definition
error.php:14
Bitrix\Main\UI\PageNavigation
Definition
pagenavigation.php:27
Bitrix\Rest\Integration\Controller\Base
Definition
base.php:21
Bitrix\Rest\Integration\Controller\Base\count
count($filter)
Definition
base.php:275
Bitrix\Rest\Integration\Controller\Base\exists
exists($id)
Definition
base.php:368
Bitrix\Rest\Integration\Controller\Base\getList
getList(array $select, array $filter, array $order, PageNavigation $pageNavigation=null)
Definition
base.php:248
Bitrix\Rest\Integration\Controller\Base\existsByFilter
existsByFilter($filter)
Definition
base.php:385
Bitrix\Rest\Integration\Controller\Base\getViewManager
getViewManager()
Definition
base.php:51
Bitrix\Sale\Exchange\Integration\Controller\StatisticProvider
Definition
statisticprovider.php:17
Bitrix\Sale\Exchange\Integration\Controller\StatisticProvider\checkDeletePermissionEntity
checkDeletePermissionEntity()
Definition
statisticprovider.php:181
Bitrix\Sale\Exchange\Integration\Controller\StatisticProvider\checkReadPermissionEntity
checkReadPermissionEntity()
Definition
statisticprovider.php:166
Bitrix\Sale\Exchange\Integration\Controller\StatisticProvider\checkCreatePermissionEntity
checkCreatePermissionEntity()
Definition
statisticprovider.php:171
Bitrix\Sale\Exchange\Integration\Controller\StatisticProvider\addAction
addAction(array $fields)
Definition
statisticprovider.php:78
Bitrix\Sale\Exchange\Integration\Controller\StatisticProvider\getEntityTable
getEntityTable()
Definition
statisticprovider.php:161
Bitrix\Sale\Exchange\Integration\Controller\StatisticProvider\updateAction
updateAction($id, array $fields)
Definition
statisticprovider.php:109
Bitrix\Sale\Exchange\Integration\Controller\StatisticProvider\getFieldsAction
getFieldsAction()
Definition
statisticprovider.php:19
Bitrix\Sale\Exchange\Integration\Controller\StatisticProvider\deleteAction
deleteAction($id)
Definition
statisticprovider.php:141
Bitrix\Sale\Exchange\Integration\Controller\StatisticProvider\getAction
getAction($id)
Definition
statisticprovider.php:56
Bitrix\Sale\Exchange\Integration\Controller\StatisticProvider\listAction
listAction($select=[], $filter=[], $order=[], PageNavigation $pageNavigation=null)
Definition
statisticprovider.php:40
Bitrix\Sale\Exchange\Integration\Controller\StatisticProvider\createViewManager
createViewManager(Action $action)
Definition
statisticprovider.php:156
Bitrix\Sale\Exchange\Integration\Controller\StatisticProvider\checkUpdatePermissionEntity
checkUpdatePermissionEntity()
Definition
statisticprovider.php:176
Bitrix\Sale\Exchange\Integration\Entity\B24IntegrationStatProviderTable
Definition
b24integrationstatprovidertable.php:23
Bitrix\Sale\Rest\View\SaleViewManager
Definition
saleviewmanager.php:29
Bitrix\Sale\Result
Definition
result.php:9
Bitrix\Sale\Exchange\Integration\Controller
Definition
scenarios.php:4
modules
sale
lib
exchange
integration
controller
statisticprovider.php
Создано системой
1.10.0