Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
Application.php
1<?php
2
4
9
11{
12 protected function processBeforeAction(Action $action): bool
13 {
14 if (!Loader::includeModule('rest'))
15 {
16 $this->addError(new Error('Module Rest is not installed.'));
17
18 return false;
19 }
20
21 return true;
22 }
23
27 public function listAction(?\CRestServer $server = null): ?array
28 {
29 if ($server && $server->getAuthType() !== \Bitrix\Rest\SessionAuth\Auth::AUTH_TYPE && !$this->isDebugEnabled())
30 {
31 $this->addError(new \Bitrix\Main\Error(
32 "Access access to test method available only for session authorization.",
33 "WRONG_AUTH_TYPE"
34 ));
35
36 return null;
37 }
38 return (new \Bitrix\Im\V2\Marketplace\Application())->toRestFormat();
39 }
40
44 public function updateAction(int $id, array $params, ?\CRestServer $server = null): ?bool
45 {
46 if ($server && $server->getAuthType() !== \Bitrix\Rest\SessionAuth\Auth::AUTH_TYPE && !$this->isDebugEnabled())
47 {
48 $this->addError(new \Bitrix\Main\Error(
49 "Access access to test method available only for session authorization.",
50 "WRONG_AUTH_TYPE"
51 ));
52
53 return null;
54 }
55
56 $params = array_change_key_case($params, CASE_UPPER);
57
58 if (isset($params['ORDER']))
59 {
60 $application = new \Bitrix\Im\V2\Marketplace\Application();
61 $result = $application->setOrder($id, (int)$params['ORDER']);
62 $this->addErrors($result->getErrors());
63 }
64
65 return true;
66 }
67
68 private function isDebugEnabled(): bool
69 {
70 $settings = \Bitrix\Main\Config\Configuration::getValue('im');
71
72 return $settings['rest_debug'] === true;
73 }
74}
updateAction(int $id, array $params, ?\CRestServer $server=null)