Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
configfactory.php
1<?php
2
4
9
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}
__construct(string $serviceUrl, string $token=null)