Bitrix-D7
23.9
Загрузка...
Поиск...
Не найдено
configfactory.php
1
<?php
2
3
namespace
Bitrix\Location\Source\Osm
;
4
5
use
Bitrix\Location\Entity\Source\Config
;
6
use
Bitrix\Location\Entity\Source\ConfigItem
;
7
use
Bitrix\Location\Source\IConfigFactory
;
8
use
Bitrix\Main\Type\DateTime
;
9
10
class
ConfigFactory
implements
IConfigFactory
11
{
12
protected
$serviceUrl
;
13
protected
$token
;
14
15
public
function
__construct
(
string
$serviceUrl
,
string
$token
=
null
)
16
{
17
$this->serviceUrl =
$serviceUrl
;
18
$this->token =
$token
;
19
}
20
21
public
function
createConfig
():
Config
22
{
23
$token
=
null
;
24
25
if
($this->token !==
null
)
26
{
27
$token
=
new
Token
(
28
(
string
)$this->token,
29
(
int
)((
new
DateTime
())->getTimestamp() + 31536000)
//year
30
);
31
32
$token
= serialize(
$token
->convertToArray());
33
}
34
35
$sourceConfig =
new
Config
();
36
37
$sourceConfig
38
->addItem(
39
(
new
ConfigItem
(
'SERVICE_URL'
,
'string'
))
40
->setSort(10)
41
->setValue($this->serviceUrl)
42
->setIsVisible(
false
)
43
)
44
->addItem(
45
(
new
ConfigItem
(
'TOKEN'
,
'string'
))
46
->setSort(20)
47
->setValue(
$token
)
48
->setIsVisible(
false
)
49
)
50
;
51
52
return
$sourceConfig;
53
}
54
}
Bitrix\Location\Entity\Source\Config
Definition
config.php:11
Bitrix\Location\Entity\Source\ConfigItem
Definition
configitem.php:13
Bitrix\Location\Source\Osm\ConfigFactory
Definition
configfactory.php:11
Bitrix\Location\Source\Osm\ConfigFactory\$token
$token
Definition
configfactory.php:13
Bitrix\Location\Source\Osm\ConfigFactory\__construct
__construct(string $serviceUrl, string $token=null)
Definition
configfactory.php:15
Bitrix\Location\Source\Osm\ConfigFactory\createConfig
createConfig()
Definition
configfactory.php:21
Bitrix\Location\Source\Osm\ConfigFactory\$serviceUrl
$serviceUrl
Definition
configfactory.php:12
Bitrix\Location\Source\Osm\Token
Definition
token.php:11
Bitrix\Main\Type\DateTime
Definition
datetime.php:9
Bitrix\Location\Source\IConfigFactory
Definition
iconfigfactory.php:8
Bitrix\Location\Source\Osm
Bitrix\Main\Config
Definition
configuration.php:2
modules
location
lib
source
osm
configfactory.php
Создано системой
1.10.0