Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
moneyconfig.php
1<?php
2
4
8
12class MoneyConfig extends Config
13{
18 private array $currencyList;
19 private ?bool $isHtml;
20
24 public function __construct(string $name, ?array $currencyList = null)
25 {
26 parent::__construct($name, Types::MONEY);
27
28 if (isset($currencyList))
29 {
30 $this->currencyList = $currencyList;
31 }
32 elseif (Loader::includeModule('currency'))
33 {
34 $this->currencyList = CurrencyManager::getSymbolList();
35 $this->setHtml(true);
36 }
37 else
38 {
39 $this->currencyList = [];
40 }
41 }
42
50 public function setHtml(bool $value): self
51 {
52 $this->isHtml = $value;
53
54 return $this;
55 }
56
62 private function getCurrenyListAsDropdown(): array
63 {
64 $result = [];
65
66 foreach ($this->currencyList as $value => $name)
67 {
68 $result[] = [
69 'VALUE' => $value,
70 'NAME' => $name,
71 ];
72 }
73
74 return $result;
75 }
76
80 public function toArray(): array
81 {
82 $result = parent::toArray();
83
84 $result['CURRENCY_LIST'] = $this->getCurrenyListAsDropdown();
85
86 if (isset($this->isHtml))
87 {
88 $result['HTML_ENTITY'] = $this->isHtml;
89 }
90
91 return $result;
92 }
93}
__construct(string $name, ?array $currencyList=null)
static includeModule($moduleName)
Definition loader.php:69