Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
ofdservice.php
1<?php
2
4
8
9if (!Main\Loader::includeModule('rest'))
10{
11 return;
12}
13
18{
25 public static function getOfdList($params, $page, $server)
26 {
27 Sale\Helpers\Rest\AccessChecker::checkAccessPermission();
28
29 return array_keys(self::getOfdHandlersMap());
30 }
31
38 public static function getOfdSettings($params, $page, $server)
39 {
40 Sale\Helpers\Rest\AccessChecker::checkAccessPermission();
41 $params = self::prepareHandlerParams($params, $server);
42 self::checkParamsBeforeOfdSettingsGet($params);
43
44 $ofdHandlersMap = self::getOfdHandlersMap();
46 $ofdClass = $ofdHandlersMap[$params['OFD']];
47 return $ofdClass::getSettings();
48 }
49
54 private static function checkParamsBeforeOfdSettingsGet(array $params)
55 {
56 if (empty($params['OFD']))
57 {
58 throw new Rest\RestException('Parameter OFD is not defined', self::ERROR_CHECK_FAILURE);
59 }
60
61 $ofdHandlersMap = self::getOfdHandlersMap();
62 if (!isset($ofdHandlersMap[$params['OFD']]))
63 {
64 throw new Rest\RestException('Ofd not found', self::ERROR_CHECK_FAILURE);
65 }
66 }
67
71 private static function getOfdHandlersMap(): array
72 {
73 static $result = [];
74
75 if (empty($result))
76 {
77 $ofdHandlers = array_keys(Sale\Cashbox\Ofd::getHandlerList());
79 foreach ($ofdHandlers as $handler)
80 {
81 $result[$handler::getCode()] = $handler;
82 }
83 }
84
85 return $result;
86 }
87}
static includeModule($moduleName)
Definition loader.php:69
static getOfdList($params, $page, $server)
static prepareHandlerParams($data, \CRestServer $server)