1C-Bitrix 25.700.0
Загрузка...
Поиск...
Не найдено
Option.php
См. документацию.
1<?php
2
3namespace Bitrix\MessageService\Providers\Base;
4
5use Bitrix\Main;
6use Bitrix\Main\Security\Cipher;
7use Bitrix\MessageService\Providers\Encryptor;
8use Bitrix\MessageService\Providers\OptionManager;
9
10class Option implements OptionManager
11{
12 use Encryptor;
13
14 protected ?array $options;
15
16 protected string $providerType;
17 protected string $providerId;
18 protected string $dbOptionName;
19
20 protected int $socketTimeout = 10;
21 protected int $streamTimeout = 30;
22
23 public function __construct(string $providerType, string $providerId)
24 {
25 $this->options = null;
26
27 $this->providerType = mb_strtolower($providerType);
28 $this->providerId = $providerId;
29
30 $this->dbOptionName = 'sender.' . $this->providerType . '.' . $this->providerId;
31 }
32
36 public function getSocketTimeout(): int
37 {
38 return $this->socketTimeout;
39 }
40
46 {
47 $this->socketTimeout = $socketTimeout;
48 return $this;
49 }
50
54 public function getStreamTimeout(): int
55 {
56 return $this->streamTimeout;
57 }
58
64 {
65 $this->streamTimeout = $streamTimeout;
66 return $this;
67 }
68
70 {
71 $this->options = $options;
72 $data = serialize($options);
73
75 'crypto' => 'Y',
76 'data' => self::encrypt($data, $this->providerType . '-' . $this->providerId)
77 ];
78
79 Main\Config\Option::set('messageservice', $this->dbOptionName, serialize($encryptedData));
80
81 return $this;
82 }
83
85 {
86 $options = $this->getOptions();
87
89 {
91 $this->setOptions($options);
92 }
93
94 return $this;
95 }
96
97 public function getOptions(): array
98 {
99 $this->options ??= $this->loadOptions();
100
101 return $this->options;
102 }
103
104 public function getOption(string $optionName, $defaultValue = null)
105 {
106 $this->getOptions();
107
108 return $this->options[$optionName] ?? $defaultValue;
109 }
110
111 public function clearOptions(): OptionManager
112 {
113 $this->options = [];
114 Main\Config\Option::delete('messageservice', array('name' => $this->dbOptionName));
115
116 return $this;
117 }
118
119 protected function loadOptions(): array
120 {
121 $data = Main\Config\Option::get('messageservice', $this->dbOptionName);
122 $data = unserialize($data, ['allowed_classes' => false]);
123
124 if (!isset($data['crypto']) && !isset($data['data']))
125 {
126 return is_array($data) ? $data : [];
127 }
128
129 $decryptedData = self::decrypt($data['data'], $this->providerType . '-' . $this->providerId);
130 $options = unserialize($decryptedData, ['allowed_classes' => false]);
131
132 return is_array($options) ? $options : [];
133 }
134
135 public function getProviderId(): string
136 {
137 return $this->providerId;
138 }
139}
if($_SERVER $defaultValue['REQUEST_METHOD']==="GET" &&!empty($RestoreDefaults) && $bizprocPerms==="W" &&check_bitrix_sessid())
Определения options.php:32
static $options
Определения option.php:18
static delete($moduleId, array $filter=array())
Определения option.php:388
static get($moduleId, $name, $default="", $siteId=false)
Определения option.php:30
static set($moduleId, $name, $value="", $siteId="")
Определения option.php:261
getOption(string $optionName, $defaultValue=null)
Определения Option.php:104
setOptions(array $options)
Определения Option.php:69
setOption(string $optionName, $optionValue)
Определения Option.php:84
setSocketTimeout(int $socketTimeout)
Определения Option.php:45
setStreamTimeout(int $streamTimeout)
Определения Option.php:63
__construct(string $providerType, string $providerId)
Определения Option.php:23
$data['IS_AVAILABLE']
Определения .description.php:13
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
Определения file_new.php:804
if(isValidSign($key, $signedUserToken)===false) $decryptedData
Определения quickway.php:264
if(!empty( $_GET[ 'ts']) &&$_GET[ 'ts']==='bxviewer') if(!empty($_GET['_gen'])) $encryptedData
Определения quickway.php:13
$optionName
Определения options.php:1735
$optionValue
Определения options.php:3512