Bitrix-D7
23.9
Загрузка...
Поиск...
Не найдено
messagesms.php
1
<?php
9
namespace
Bitrix\Sender\Integration\MessageService\Sms
;
10
11
use
Bitrix\Main\Localization\Loc
;
12
use
Bitrix\Main\Result
;
13
use
Bitrix\Sender\Message
;
14
use
Bitrix\Sender\Entity
;
15
use
Bitrix\Main\Config\Option
;
16
use
Bitrix\Sender\Transport\TimeLimiter
;
17
18
Loc::loadMessages
(__FILE__);
19
24
class
MessageSms
implements
Message\iBase
,
Message\iMailable
25
{
26
const
CODE
=
self::CODE_SMS
;
27
29
protected
$configuration
;
30
32
protected
$configurationId
;
33
37
public
function
__construct
()
38
{
39
$this->configuration =
new
Message\Configuration
();
40
}
41
46
public
function
getName
()
47
{
48
return
Loc::getMessage
(
'SENDER_INTEGRATION_SMS_MESSAGE_NAME'
);
49
}
50
51
public
function
getCode
()
52
{
53
return
static::CODE;
54
}
55
56
public
function
getSupportedTransports
()
57
{
58
return
array(
TransportSms::CODE
);
59
}
60
61
protected
function
setConfigurationOptions
()
62
{
63
if
($this->configuration->hasOptions())
64
{
65
return
;
66
}
67
68
$this->configuration->setArrayOptions(array(
69
array(
70
'type'
=>
'string'
,
71
'code'
=>
'SENDER'
,
72
'name'
=>
Loc::getMessage
(
'SENDER_INTEGRATION_SMS_MESSAGE_CONFIG_SENDER'
),
73
'required'
=>
true
,
74
'show_in_list'
=>
true
,
75
'readonly_view'
=>
function
($value)
76
{
77
return
Service::getFormattedOutputNumber
($value);
78
},
79
),
80
array(
81
'type'
=>
'text'
,
82
'code'
=>
'MESSAGE_TEXT'
,
83
'name'
=>
Loc::getMessage
(
'SENDER_INTEGRATION_SMS_MESSAGE_CONFIG_MESSAGE_TEXT'
),
84
'required'
=>
true
,
85
),
86
));
87
88
TimeLimiter::prepareMessageConfiguration($this->configuration);
89
}
90
98
public
function
loadConfiguration
($id =
null
)
99
{
100
$this->
setConfigurationOptions
();
101
Entity\Message::create()
102
->setCode($this->
getCode
())
103
->loadConfiguration($id, $this->configuration);
104
105
$senderOption = $this->configuration->getOption(
'SENDER'
);
106
if
($senderOption)
107
{
108
$senderOption->setView(
109
function
() use ($senderOption)
110
{
111
ob_start();
112
$GLOBALS
[
'APPLICATION'
]->includeComponent(
113
"bitrix:sender.sms.sender"
,
114
".default"
,
115
array(
116
"INPUT_NAME"
=>
"%INPUT_NAME%"
,
117
"SENDER"
=> $senderOption->getValue()
118
)
119
);
120
121
return
ob_get_clean();
122
}
123
);
124
}
125
126
$textOption = $this->configuration->getOption(
'MESSAGE_TEXT'
);
127
if
($textOption)
128
{
129
$textOption->setView(
130
function
()
131
{
132
ob_start();
133
$GLOBALS
[
'APPLICATION'
]->includeComponent(
134
"bitrix:sender.sms.text.editor"
,
135
".default"
,
136
array(
137
"INPUT_NAME"
=>
"%INPUT_NAME%"
,
138
"VALUE"
=>
"%INPUT_VALUE%"
,
139
)
140
);
141
142
return
ob_get_clean();
143
}
144
);
145
}
146
TimeLimiter::prepareMessageConfigurationView($this->configuration);
147
148
return
$this->configuration
;
149
}
150
158
public
function
saveConfiguration
(
Message
\
Configuration
$configuration
)
159
{
160
return
Entity\Message::create()
161
->setCode($this->
getCode
())
162
->saveConfiguration($this->configuration);
163
}
164
171
public
function
removeConfiguration
($id)
172
{
173
$result = Entity\Message::removeById($id);
174
return
$result->isSuccess();
175
}
176
183
public
function
copyConfiguration
($id)
184
{
185
return
Entity\Message::create()
186
->setCode($this->
getCode
())
187
->copyConfiguration($id);
188
}
189
195
public
function
getSmsSender
()
196
{
197
return
$this->configuration->getOption(
'SENDER'
)->getValue();
198
}
199
}
Bitrix\Main\Config\Configuration
Definition
configuration.php:7
Bitrix\Main\Config\Option
Definition
option.php:15
Bitrix\Main\Localization\Loc
Definition
loc.php:11
Bitrix\Main\Localization\Loc\loadMessages
static loadMessages($file)
Definition
loc.php:64
Bitrix\Main\Localization\Loc\getMessage
static getMessage($code, $replace=null, $language=null)
Definition
loc.php:29
Bitrix\Main\ORM\Data\Result
Definition
result.php:16
Bitrix\MessageService\Message
Definition
message.php:18
Bitrix\Sender\Integration\MessageService\Sms\MessageSms
Definition
messagesms.php:25
Bitrix\Sender\Integration\MessageService\Sms\MessageSms\CODE
const CODE
Definition
messagesms.php:26
Bitrix\Sender\Integration\MessageService\Sms\MessageSms\__construct
__construct()
Definition
messagesms.php:37
Bitrix\Sender\Integration\MessageService\Sms\MessageSms\getSmsSender
getSmsSender()
Definition
messagesms.php:195
Bitrix\Sender\Integration\MessageService\Sms\MessageSms\setConfigurationOptions
setConfigurationOptions()
Definition
messagesms.php:61
Bitrix\Sender\Integration\MessageService\Sms\MessageSms\getName
getName()
Definition
messagesms.php:46
Bitrix\Sender\Integration\MessageService\Sms\MessageSms\removeConfiguration
removeConfiguration($id)
Definition
messagesms.php:171
Bitrix\Sender\Integration\MessageService\Sms\MessageSms\loadConfiguration
loadConfiguration($id=null)
Definition
messagesms.php:98
Bitrix\Sender\Integration\MessageService\Sms\MessageSms\$configuration
$configuration
Definition
messagesms.php:29
Bitrix\Sender\Integration\MessageService\Sms\MessageSms\getCode
getCode()
Definition
messagesms.php:51
Bitrix\Sender\Integration\MessageService\Sms\MessageSms\$configurationId
$configurationId
Definition
messagesms.php:32
Bitrix\Sender\Integration\MessageService\Sms\MessageSms\copyConfiguration
copyConfiguration($id)
Definition
messagesms.php:183
Bitrix\Sender\Integration\MessageService\Sms\MessageSms\saveConfiguration
saveConfiguration(Message\Configuration $configuration)
Definition
messagesms.php:158
Bitrix\Sender\Integration\MessageService\Sms\MessageSms\getSupportedTransports
getSupportedTransports()
Definition
messagesms.php:56
Bitrix\Sender\Integration\MessageService\Sms\Service\getFormattedOutputNumber
static getFormattedOutputNumber($value)
Definition
service.php:202
Bitrix\Sender\Integration\MessageService\Sms\TransportSms\CODE
const CODE
Definition
transportsms.php:26
Bitrix\Sender\Transport\TimeLimiter
Definition
timelimiter.php:16
Bitrix\Sender\Message\iBase
Definition
ibase.php:16
Bitrix\Sender\Message\iBase\CODE_SMS
const CODE_SMS
Definition
ibase.php:20
Bitrix\Sender\Message\iMailable
Definition
imailable.php:16
Bitrix\Main\$GLOBALS
$GLOBALS['____1444769544']
Definition
license.php:1
Bitrix\Sender\Entity
Definition
ad.php:8
Bitrix\Sender\Integration\MessageService\Sms
Definition
messagesms.php:9
Bitrix\Sender\Message
Definition
adapter.php:9
modules
sender
lib
integration
messageservice
sms
messagesms.php
Создано системой
1.10.0