Bitrix-D7
23.9
Загрузка...
Поиск...
Не найдено
store.php
1
<?php
2
3
4
namespace
Bitrix\Catalog\Controller
;
5
6
7
use
Bitrix\Catalog\Access\ActionDictionary
;
8
use
Bitrix\Catalog\StoreTable
;
9
use
Bitrix\Main\Engine\Response\DataType\Page
;
10
use
Bitrix\Main\Error
;
11
use
Bitrix\Main\Result
;
12
use
Bitrix\Main\UI\PageNavigation
;
13
14
final
class
Store
extends
Controller
15
{
16
//region Actions
17
public
function
getFieldsAction
(): array
18
{
19
return
[
'STORE'
=> $this->
getViewFields
()];
20
}
21
22
public
function
listAction
(
PageNavigation
$pageNavigation, array $select = [], array $filter = [], array $order = []):
Page
23
{
24
$accessFilter = $this->accessController->getEntityFilter(
25
ActionDictionary::ACTION_STORE_VIEW,
26
get_class($this->
getEntityTable
())
27
);
28
if
($accessFilter)
29
{
30
$filter = [
31
$accessFilter,
32
$filter,
33
];
34
}
35
36
return
new
Page
(
37
'STORES'
,
38
$this->getList($select, $filter, $order, $pageNavigation),
39
$this->count($filter)
40
);
41
}
42
43
public
function
addAction
(array $fields)
44
{
45
$view = $this->getViewManager()
46
->getView($this);
47
$fields = $view->internalizeFieldsAdd($fields);
48
49
$res = $this->add($fields);
50
if
($res->isSuccess())
51
{
52
$result = $res->getId();
53
}
54
else
55
{
56
$result = [
57
'error'
=>
'ERROR_ADD'
,
58
'error_description'
=> implode(
59
'. '
,
60
$res->getErrorMessages()
61
),
62
];
63
}
64
65
return
$result;
66
}
67
68
public
function
updateAction
(
int
$id, array $fields)
69
{
70
$view = $this->getViewManager()
71
->getView($this);
72
$fields = $view->internalizeFieldsUpdate($fields);
73
74
$res = $this->update($id, $fields);
75
if
(!is_null($res) && $res->isSuccess())
76
{
77
$result = $res->getId();
78
}
79
else
80
{
81
$result = [
82
'error'
=>
'ERROR_UPDATE'
,
83
'error_description'
=> implode(
84
'. '
,
85
$this->
getErrors
()
86
),
87
];
88
}
89
90
return
$result;
91
}
92
93
public
function
deleteAction
(
int
$id)
94
{
95
$res = $this->
delete
($id);
96
if
(!is_null($res) && $res->isSuccess())
97
{
98
$result =
'Y'
;
99
}
100
else
101
{
102
$result = [
103
'error'
=>
'ERROR_DELETE'
,
104
'error_description'
=> implode(
105
'. '
,
106
$this->
getErrors
()
107
),
108
];
109
}
110
111
return
$result;
112
}
113
114
public
function
getAction
($id)
115
{
116
$r = $this->
exists
($id);
117
if
($r->isSuccess())
118
{
119
return
[
'STORE'
=>$this->
get
($id)];
120
}
121
else
122
{
123
$this->addErrors($r->getErrors());
124
return
null
;
125
}
126
}
127
//endregion
128
129
protected
function
exists
($id)
130
{
131
$r =
new
Result
();
132
if
(isset($this->
get
($id)[
'ID'
]) ==
false
)
133
$r->addError(
new
Error
(
'Store is not exists'
));
134
135
return
$r;
136
}
137
138
protected
function
getEntityTable
()
139
{
140
return
new
StoreTable
();
141
}
142
143
protected
function
checkModifyPermissionEntity
()
144
{
145
$r =
new
Result
();
146
147
if
(!$this->accessController->check(ActionDictionary::ACTION_STORE_MODIFY))
148
{
149
$r->addError(
new
Error
(
'Access Denied'
, 200040300020));
150
}
151
152
return
$r;
153
}
154
155
protected
function
checkReadPermissionEntity
()
156
{
157
$r =
new
Result
();
158
159
if
(
160
!(
161
$this->accessController->check(ActionDictionary::ACTION_CATALOG_READ)
162
|| $this->accessController->check(ActionDictionary::ACTION_STORE_VIEW)
163
|| $this->accessController->check(ActionDictionary::ACTION_STORE_MODIFY)
164
)
165
)
166
{
167
$r->addError(
new
Error
(
'Access Denied'
, 200040300010));
168
}
169
return
$r;
170
}
171
}
Bitrix\Catalog\Access\ActionDictionary
Definition
ActionDictionary.php:17
Bitrix\Catalog\Controller\Controller\getViewFields
getViewFields()
Definition
controller.php:95
Bitrix\Catalog\Controller\Store
Definition
store.php:15
Bitrix\Catalog\Controller\Store\checkModifyPermissionEntity
checkModifyPermissionEntity()
Definition
store.php:143
Bitrix\Catalog\Controller\Store\checkReadPermissionEntity
checkReadPermissionEntity()
Definition
store.php:155
Bitrix\Catalog\Controller\Store\exists
exists($id)
Definition
store.php:129
Bitrix\Catalog\Controller\Store\addAction
addAction(array $fields)
Definition
store.php:43
Bitrix\Catalog\Controller\Store\getEntityTable
getEntityTable()
Definition
store.php:138
Bitrix\Catalog\Controller\Store\getFieldsAction
getFieldsAction()
Definition
store.php:17
Bitrix\Catalog\Controller\Store\deleteAction
deleteAction(int $id)
Definition
store.php:93
Bitrix\Catalog\Controller\Store\updateAction
updateAction(int $id, array $fields)
Definition
store.php:68
Bitrix\Catalog\Controller\Store\listAction
listAction(PageNavigation $pageNavigation, array $select=[], array $filter=[], array $order=[])
Definition
store.php:22
Bitrix\Catalog\Controller\Store\getAction
getAction($id)
Definition
store.php:114
Bitrix\Catalog\StoreTable
Definition
store.php:55
Bitrix\Main\DB\Result
Definition
result.php:19
Bitrix\Main\Engine\Response\DataType\Page
Definition
page.php:8
Bitrix\Main\Error
Definition
error.php:14
Bitrix\Main\ORM\Data\Result
Definition
result.php:16
Bitrix\Main\UI\PageNavigation
Definition
pagenavigation.php:27
Bitrix\Catalog\Controller
Bitrix\Main\getErrors
getErrors()
Definition
errorableimplementation.php:34
Bitrix\Sender\Internals\QueryController
Definition
action.php:8
modules
catalog
lib
controller
store.php
Создано системой
1.10.0