Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
storeproduct.php
1<?php
2
4
11
12final 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}
listAction(PageNavigation $pageNavigation, array $select=[], array $filter=[], array $order=[])