Bitrix-D7
23.9
Загрузка...
Поиск...
Не найдено
config.php
1
<?php
2
namespace
Bitrix\Main\Mail\Callback
;
3
4
use
Bitrix\Main\ArgumentTypeException
;
5
use
Bitrix\Main\ArgumentException
;
6
use
Bitrix\Main\Security\Sign\Signer
;
7
13
class
Config
14
{
15
const
SIGHT_SALT
=
'main_mail_callback'
;
16
18
protected
$moduleId
;
19
21
protected
$entityType
;
22
24
protected
$entityId
;
25
27
protected
$id
;
28
30
protected
$host
;
31
37
public
function
getModuleId
()
38
{
39
return
$this->moduleId;
40
}
41
49
public
function
setModuleId
($moduleId)
50
{
51
if
(empty(
$moduleId
))
52
{
53
throw
new
ArgumentException
(
'Parameters `$moduleId` required.'
);
54
}
55
56
$this->
id
=
null
;
57
$this->moduleId =
$moduleId
;
58
return
$this;
59
}
60
66
public
function
getEntityType
()
67
{
68
return
$this->entityType;
69
}
70
79
public
function
setEntityType
($entityType)
80
{
81
$this->
id
=
null
;
82
$this->entityType =
$entityType
?:
null
;
83
return
$this;
84
}
85
93
public
function
getEntityId
()
94
{
95
return
$this->entityId;
96
}
97
105
public
function
setEntityId
($entityId)
106
{
107
if
(empty(
$entityId
))
108
{
109
throw
new
ArgumentException
(
'Parameters `$entityId` required.'
);
110
}
111
112
$this->
id
=
null
;
113
$this->entityId =
$entityId
;
114
return
$this;
115
}
116
123
public
function
setHost
($host)
124
{
125
$this->host =
$host
;
126
return
$this;
127
}
128
134
public
function
getHost
()
135
{
136
return
$this->host;
137
}
138
139
145
public
function
getId
()
146
{
147
if
(!$this->
id
)
148
{
149
$this->
id
= self::generateId(
150
$this->
getModuleId
(),
151
$this->
getEntityType
(),
152
$this->
getEntityId
()
153
);
154
}
155
156
return
$this->id;
157
}
158
164
public
function
getSignature
()
165
{
166
try
167
{
168
return
(
new
Signer
())->getSignature($this->
getSignedString
(), self::SIGHT_SALT);
169
}
170
catch
(
ArgumentTypeException
$exception)
171
{
172
return
null
;
173
}
174
}
175
182
public
function
verifySignature
($signature)
183
{
184
return
(
new
Signer
())->validate(
185
$this->
getSignedString
(),
186
$signature,
187
self::SIGHT_SALT
188
);
189
}
190
191
protected
function
getSignedString
()
192
{
193
return
$this->
getId
();
194
}
195
205
public
static
function
generateId
($moduleId, $entityType =
null
, $entityId)
206
{
207
$entityType
=
$entityType
?:
''
;
208
return
base64_encode(
"$moduleId/$entityType/$entityId"
);
209
}
210
218
public
function
unpackId
($id)
219
{
220
$id
= base64_decode(
$id
);
221
$list = explode(
'/'
,
$id
);
222
$this->
setModuleId
($list[0]);
223
$this->
setEntityType
($list[1]);
224
$this->
setEntityId
($list[2]);
225
226
return
$this;
227
}
228
}
Bitrix\Main\ArgumentException
Definition
exception.php:34
Bitrix\Main\ArgumentTypeException
Definition
exception.php:114
Bitrix\Main\Mail\Callback\Config\getEntityId
getEntityId()
Definition
config.php:93
Bitrix\Main\Mail\Callback\Config\getId
getId()
Definition
config.php:145
Bitrix\Main\Mail\Callback\Config\$entityType
$entityType
Definition
config.php:21
Bitrix\Main\Mail\Callback\Config\SIGHT_SALT
const SIGHT_SALT
Definition
config.php:15
Bitrix\Main\Mail\Callback\Config\setHost
setHost($host)
Definition
config.php:123
Bitrix\Main\Mail\Callback\Config\verifySignature
verifySignature($signature)
Definition
config.php:182
Bitrix\Main\Mail\Callback\Config\getHost
getHost()
Definition
config.php:134
Bitrix\Main\Mail\Callback\Config\generateId
static generateId($moduleId, $entityType=null, $entityId)
Definition
config.php:205
Bitrix\Main\Mail\Callback\Config\getSignedString
getSignedString()
Definition
config.php:191
Bitrix\Main\Mail\Callback\Config\getSignature
getSignature()
Definition
config.php:164
Bitrix\Main\Mail\Callback\Config\setEntityId
setEntityId($entityId)
Definition
config.php:105
Bitrix\Main\Mail\Callback\Config\$host
$host
Definition
config.php:30
Bitrix\Main\Mail\Callback\Config\setModuleId
setModuleId($moduleId)
Definition
config.php:49
Bitrix\Main\Mail\Callback\Config\unpackId
unpackId($id)
Definition
config.php:218
Bitrix\Main\Mail\Callback\Config\getModuleId
getModuleId()
Definition
config.php:37
Bitrix\Main\Mail\Callback\Config\$moduleId
$moduleId
Definition
config.php:18
Bitrix\Main\Mail\Callback\Config\getEntityType
getEntityType()
Definition
config.php:66
Bitrix\Main\Mail\Callback\Config\$entityId
$entityId
Definition
config.php:24
Bitrix\Main\Mail\Callback\Config\$id
$id
Definition
config.php:27
Bitrix\Main\Mail\Callback\Config\setEntityType
setEntityType($entityType)
Definition
config.php:79
Bitrix\Main\Security\Sign\Signer
Definition
signer.php:13
Bitrix\Main\Config
Definition
configuration.php:2
Bitrix\Main\Mail\Callback
Definition
config.php:2
modules
main
lib
mail
callback
config.php
Создано системой
1.10.0