Bitrix-D7
23.9
Загрузка...
Поиск...
Не найдено
storeproduct.php
1
<?php
2
3
namespace
Bitrix\Catalog\Controller
;
4
5
use
Bitrix\Catalog\Access\ActionDictionary
;
6
use
Bitrix\Catalog\StoreProductTable
;
7
use
Bitrix\Main\Engine\Response\DataType\Page
;
8
use
Bitrix\Main\Error
;
9
use
Bitrix\Main\Result
;
10
use
Bitrix\Main\UI\PageNavigation
;
11
12
final
class
StoreProduct
extends
Controller
13
{
14
protected
const
ITEM
=
'STORE_PRODUCT'
;
15
protected
const
LIST
=
'STORE_PRODUCTS'
;
16
17
//region Actions
18
public
function
getFieldsAction
(): array
19
{
20
return
[self::ITEM => $this->
getViewFields
()];
21
}
22
23
public
function
listAction
(
PageNavigation
$pageNavigation, array $select = [], array $filter = [], array $order = []):
Page
24
{
25
$accessFilter = $this->accessController->getEntityFilter(
26
ActionDictionary::ACTION_STORE_VIEW,
27
get_class($this->
getEntityTable
())
28
);
29
if
($accessFilter)
30
{
31
$filter = [
32
$accessFilter,
33
$filter,
34
];
35
}
36
37
return
new
Page
(
38
self::LIST,
39
$this->getList($select, $filter, $order, $pageNavigation),
40
$this->count($filter)
41
);
42
}
43
44
public
function
getAction
($id)
45
{
46
$r = $this->
exists
($id);
47
if
($r->isSuccess())
48
{
49
return
[self::ITEM => $this->
get
($id)];
50
}
51
else
52
{
53
$this->addErrors($r->getErrors());
54
return
null
;
55
}
56
}
57
//endregion
58
59
protected
function
exists
($id)
60
{
61
$r =
new
Result
();
62
if
(isset($this->
get
($id)[
'ID'
]) ==
false
)
63
$r->addError(
new
Error
(
'Entity is not exists'
));
64
65
return
$r;
66
}
67
68
protected
function
getEntityTable
()
69
{
70
return
new
StoreProductTable
();
71
}
72
73
protected
function
checkReadPermissionEntity
()
74
{
75
$r =
new
Result
();
76
77
if
(!(
78
$this->accessController->check(ActionDictionary::ACTION_CATALOG_READ)
79
|| $this->accessController->check(ActionDictionary::ACTION_STORE_VIEW)
80
))
81
{
82
$r->addError(
new
Error
(
'Access Denied'
, 200040300010));
83
}
84
return
$r;
85
}
86
}
Bitrix\Catalog\Access\ActionDictionary
Definition
ActionDictionary.php:17
Bitrix\Catalog\Controller\Controller\getViewFields
getViewFields()
Definition
controller.php:95
Bitrix\Catalog\Controller\StoreProduct
Definition
storeproduct.php:13
Bitrix\Catalog\Controller\StoreProduct\checkReadPermissionEntity
checkReadPermissionEntity()
Definition
storeproduct.php:73
Bitrix\Catalog\Controller\StoreProduct\exists
exists($id)
Definition
storeproduct.php:59
Bitrix\Catalog\Controller\StoreProduct\getEntityTable
getEntityTable()
Definition
storeproduct.php:68
Bitrix\Catalog\Controller\StoreProduct\getFieldsAction
getFieldsAction()
Definition
storeproduct.php:18
Bitrix\Catalog\Controller\StoreProduct\listAction
listAction(PageNavigation $pageNavigation, array $select=[], array $filter=[], array $order=[])
Definition
storeproduct.php:23
Bitrix\Catalog\Controller\StoreProduct\LIST
const LIST
Definition
storeproduct.php:15
Bitrix\Catalog\Controller\StoreProduct\getAction
getAction($id)
Definition
storeproduct.php:44
Bitrix\Catalog\Controller\StoreProduct\ITEM
const ITEM
Definition
storeproduct.php:14
Bitrix\Catalog\StoreProductTable
Definition
storeproduct.php:39
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\Sender\Internals\QueryController
Definition
action.php:8
modules
catalog
lib
controller
storeproduct.php
Создано системой
1.10.0