Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
statisticprovider.php
1<?php
2
3
5
6
15
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 {
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}
getList(array $select, array $filter, array $order, PageNavigation $pageNavigation=null)
Definition base.php:248
listAction($select=[], $filter=[], $order=[], PageNavigation $pageNavigation=null)