Bitrix-D7
23.9
Загрузка...
Поиск...
Не найдено
message.php
1
<?php
8
namespace
Bitrix\Main\Sms
;
9
10
use
Bitrix\Main\Config
;
11
12
class
Message
13
{
14
protected
$sender
;
15
protected
$receiver
;
16
protected
$text
;
17
protected
$template
;
18
19
public
function
__construct
()
20
{
21
}
22
23
public
static
function
createFromTemplate
(
Template
$template
, array $fields)
24
{
25
$message =
new
static
();
26
$message->template =
$template
;
27
28
if
(!isset($fields[
"SITE_NAME"
]))
29
{
30
$fields[
"SITE_NAME"
] =
$template
->getSites()->getAll()[0]->getSiteName();
31
if
($fields[
"SITE_NAME"
] ==
''
)
32
{
33
$fields[
"SITE_NAME"
] = Config\Option::get(
"main"
,
"site_name"
);
34
}
35
}
36
if
(!isset($fields[
"SERVER_NAME"
]))
37
{
38
$fields[
"SERVER_NAME"
] =
$template
->getSites()->getAll()[0]->getServerName();
39
if
($fields[
"SERVER_NAME"
] ==
''
)
40
{
41
$fields[
"SERVER_NAME"
] = Config\Option::get(
"main"
,
"server_name"
);
42
}
43
}
44
if
(!isset($fields[
"DEFAULT_SENDER"
]))
45
{
46
$fields[
"DEFAULT_SENDER"
] = Config\Option::get(
"main"
,
"sms_default_sender"
);
47
}
48
49
$message
50
->setSender(static::compile(
$template
->getSender(), $fields))
51
->setReceiver(static::compile(
$template
->getReceiver(), $fields))
52
->setText(static::compile(
$template
->getMessage(), $fields));
53
54
return
$message;
55
}
56
57
protected
static
function
compile
($string, array $fields)
58
{
59
foreach
($fields as $field => $value)
60
{
61
$string = str_replace(
"#"
.$field.
"#"
, $value, $string);
62
}
63
return
$string;
64
}
65
66
public
function
getSender
()
67
{
68
return
$this->sender
;
69
}
70
71
public
function
getReceiver
()
72
{
73
return
$this->receiver
;
74
}
75
76
public
function
getText
()
77
{
78
return
$this->text
;
79
}
80
85
public
function
setSender
(
$sender
)
86
{
87
$this->sender =
$sender
;
88
return
$this;
89
}
90
95
public
function
setReceiver
(
$receiver
)
96
{
97
$this->receiver =
$receiver
;
98
return
$this;
99
}
100
105
public
function
setText
(
$text
)
106
{
107
$this->text =
$text
;
108
return
$this;
109
}
110
114
public
function
getTemplate
(): ?
Template
115
{
116
return
$this->template
;
117
}
118
}
Bitrix\Main\Sms\Message
Definition
message.php:13
Bitrix\Main\Sms\Message\__construct
__construct()
Definition
message.php:19
Bitrix\Main\Sms\Message\getSender
getSender()
Definition
message.php:66
Bitrix\Main\Sms\Message\getTemplate
getTemplate()
Definition
message.php:114
Bitrix\Main\Sms\Message\setReceiver
setReceiver($receiver)
Definition
message.php:95
Bitrix\Main\Sms\Message\createFromTemplate
static createFromTemplate(Template $template, array $fields)
Definition
message.php:23
Bitrix\Main\Sms\Message\getText
getText()
Definition
message.php:76
Bitrix\Main\Sms\Message\$receiver
$receiver
Definition
message.php:15
Bitrix\Main\Sms\Message\$template
$template
Definition
message.php:17
Bitrix\Main\Sms\Message\setSender
setSender($sender)
Definition
message.php:85
Bitrix\Main\Sms\Message\getReceiver
getReceiver()
Definition
message.php:71
Bitrix\Main\Sms\Message\$text
$text
Definition
message.php:16
Bitrix\Main\Sms\Message\setText
setText($text)
Definition
message.php:105
Bitrix\Main\Sms\Message\compile
static compile($string, array $fields)
Definition
message.php:57
Bitrix\Main\Sms\Message\$sender
$sender
Definition
message.php:14
Bitrix\Main\Sms\Template
Definition
template.php:11
Bitrix\Main\Config
Definition
configuration.php:2
Bitrix\Main\Sms
Definition
event.php:8
modules
main
lib
sms
message.php
Создано системой
1.10.0