1C-Bitrix 25.700.0
Загрузка...
Поиск...
Не найдено
vat.php
См. документацию.
1<?php
2
3namespace Bitrix\Catalog\Controller;
4
5use Bitrix\Catalog\Access\ActionDictionary;
6use Bitrix\Catalog\VatTable;
7use Bitrix\Main\Error;
8use Bitrix\Main\Result;
9
13final class Vat extends Controller
14{
15 use ListAction; // default listAction realization
16 use GetAction; // default getAction realization
17 use CheckExists; // default implementation of existence check
18
19 //region Actions
20
25 public function addAction(array $fields): ?array
26 {
28 $application->ResetException();
29
30 $addResult = \CCatalogVat::Add($fields);
31 if (!$addResult)
32 {
33 if ($application->GetException())
34 {
35 $this->addError(new Error($application->GetException()->GetString()));
36 }
37 else
38 {
39 $this->addError(new Error('Error adding VAT'));
40 }
41
42 return null;
43 }
44
45 return [$this->getServiceItemName() => $this->get($addResult)];
46 }
47
53 public function updateAction(int $id, array $fields): ?array
54 {
55 $existsResult = $this->exists($id);
56 if (!$existsResult->isSuccess())
57 {
58 $this->addErrors($existsResult->getErrors());
59
60 return null;
61 }
62
63 $updateResult = \CCatalogVat::Update($id, $fields);
64 if (!$updateResult)
65 {
66 $this->addError(new Error('Error updating VAT'));
67
68 return null;
69 }
70
71 return [$this->getServiceItemName() => $this->get($id)];
72 }
73
78 public function deleteAction(int $id): ?bool
79 {
80 $existsResult = $this->exists($id);
81 if (!$existsResult->isSuccess())
82 {
83 $this->addErrors($existsResult->getErrors());
84
85 return null;
86 }
87
88 $deleteResult = \CCatalogVat::Delete($id);
89 if (!$deleteResult)
90 {
91 $this->addError(new Error('Error deleting VAT'));
92
93 return null;
94 }
95
96 return true;
97 }
98
102 public function getFieldsAction(): array
103 {
104 return [$this->getServiceItemName() => $this->getViewFields()];
105 }
106
111
116
120 protected function getEntityTable()
121 {
122 return new VatTable();
123 }
124
128 protected function checkModifyPermissionEntity()
129 {
130 $r = new Result();
131
132 if (!$this->accessController->check(ActionDictionary::ACTION_VAT_EDIT))
133 {
134 $r->addError($this->getErrorModifyAccessDenied());
135 }
136
137 return $r;
138 }
139
143 protected function checkReadPermissionEntity()
144 {
145 $r = new Result();
146
147 if (
148 !$this->accessController->check(ActionDictionary::ACTION_CATALOG_READ)
149 && !$this->accessController->check(ActionDictionary::ACTION_VAT_EDIT)
150 )
151 {
152 $r->addError($this->getErrorReadAccessDenied());
153 }
154
155 return $r;
156 }
157
158 protected function getErrorCodeEntityNotExists(): string
159 {
161 }
162}
static getApplication()
Определения controller.php:56
const VAT_ENTITY_NOT_EXISTS
Определения errorcode.php:23
checkModifyPermissionEntity()
Определения vat.php:128
checkReadPermissionEntity()
Определения vat.php:143
getErrorCodeEntityNotExists()
Определения vat.php:158
addAction(array $fields)
Определения vat.php:25
getEntityTable()
Определения vat.php:120
getFieldsAction()
Определения vat.php:102
deleteAction(int $id)
Определения vat.php:78
updateAction(int $id, array $fields)
Определения vat.php:53
Определения vat.php:38
Определения error.php:15
static Add($fields)
Определения vat.php:173
static Delete($id)
Определения vat.php:234
static Update($id, $fields)
Определения vat.php:206
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
Определения file_new.php:804
$application
Определения bitrix.php:23
exists($id)
Определения checkexists.php:30
trait CheckExists
Определения checkexists.php:8
trait GetAction
Определения getaction.php:8
trait ListAction
Определения listaction.php:9
$fields
Определения yandex_run.php:501