1C-Bitrix 25.700.0
Загрузка...
Поиск...
Не найдено
base.php
См. документацию.
1<?php
3
9
10abstract class Base
11{
15
16 protected int $socketTimeout = 10;
17 protected int $streamTimeout = 30;
18
23 public function setSocketTimeout(int $socketTimeout): Base
24 {
25 $this->socketTimeout = $socketTimeout;
26 return $this;
27 }
28
33 public function setStreamTimeout(int $streamTimeout): Base
34 {
35 $this->streamTimeout = $streamTimeout;
36 return $this;
37 }
38
42 public static function isSupported()
43 {
44 return true;
45 }
46
48 public static function className()
49 {
50 return get_called_class();
51 }
52
53 public function isConfigurable()
54 {
55 return false;
56 }
57
58 public function getType()
59 {
60 return MessageType::SMS;
61 }
62
63 abstract public function getId();
64
65 public function getExternalId()
66 {
67 return $this->getType().':'.$this->getId();
68 }
69
73 abstract public function getName();
74
78 abstract public function getShortName();
79
84 abstract public function canUse();
85
86 abstract public function getFromList();
87
92 public function getDefaultFrom()
93 {
94 $fromList = $this->getFromList();
95 $from = isset($fromList[0]) ? $fromList[0]['id'] : null;
96 //Try to find alphanumeric from
97 foreach ($fromList as $item)
98 {
99 if (!preg_match('#^[0-9]+$#', $item['id']))
100 {
101 $from = $item['id'];
102 break;
103 }
104 }
105 return $from;
106 }
107
111 public function getFirstFromList()
112 {
113 $fromList = $this->getFromList();
114 if (!is_array($fromList))
115 {
116 return null;
117 }
118
119 foreach ($fromList as $item)
120 {
121 if (isset($item['id']) && $item['id'])
122 {
123 return $item['id'];
124 }
125 }
126
127 return null;
128 }
129
134 public function isCorrectFrom($from)
135 {
136 $fromList = $this->getFromList();
137 foreach ($fromList as $item)
138 {
139 if ($from === $item['id'])
140 {
141 return true;
142 }
143 }
144 return false;
145 }
146
151 abstract public function sendMessage(array $messageFieldsFields);
152
159 public static function resolveStatus($serviceStatus)
160 {
162 }
163
164 public function getManageUrl()
165 {
166 return $this->isConfigurable() ? '/crm/configs/sms/?sender='.$this->getId() : '';
167 }
168
172 public function prepareMessageBodyForSave(string $text): string
173 {
174 return Emoji::encode($text);
175 }
176
177 protected function prepareMessageBodyForSend(string $text): string
178 {
179 return Emoji::decode($text);
180 }
181
182 public function sendTemplate(string $name, string $text, array $examples = [], ?string $langCode = null): Result
183 {
184 return new Result;
185 }
186}
Определения emoji.php:10
Providers Initiator $initiator
Определения base.php:13
sendMessage(array $messageFieldsFields)
int $socketTimeout
Определения base.php:16
Providers Informant $informant
Определения base.php:12
setSocketTimeout(int $socketTimeout)
Определения base.php:23
prepareMessageBodyForSave(string $text)
Определения base.php:172
int $streamTimeout
Определения base.php:17
setStreamTimeout(int $streamTimeout)
Определения base.php:33
prepareMessageBodyForSend(string $text)
Определения base.php:177
sendTemplate(string $name, string $text, array $examples=[], ?string $langCode=null)
Определения base.php:182
isCorrectFrom($from)
Определения base.php:134
static resolveStatus($serviceStatus)
Определения base.php:159
Providers Sender $sender
Определения base.php:14
static isSupported()
Определения base.php:42
static className()
Определения base.php:48
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
Определения file_new.php:804
$name
Определения menu_edit.php:35
$text
Определения template_pdf.php:79