Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
Registrar.php
1<?php
2
4
8
9abstract class Registrar implements Providers\Registrar
10{
12 protected string $providerId;
13
14 public function __construct(string $providerId, Providers\OptionManager $optionManager)
15 {
16 $this->providerId = $providerId;
17 $this->optionManager = $optionManager;
18 }
19
20 public function isConfirmed(): bool
21 {
22 return $this->isRegistered();
23 }
24
25 public function confirmRegistration(array $fields): Result
26 {
27 return new Result();
28 }
29
30 public function sendConfirmationCode(): Result
31 {
32 return new Result();
33 }
34
35 public function sync(): Registrar
36 {
37 return $this;
38 }
39
40 public function getCallbackUrl(): string
41 {
42 return $this->getHostUrl() . '/bitrix/tools/messageservice/callback_' . $this->providerId . '.php';
43 }
44
45 public function getHostUrl(): string
46 {
47 $protocol = (Context::getCurrent()->getRequest()->isHttps() ? 'https' : 'http');
48 if (defined("SITE_SERVER_NAME") && SITE_SERVER_NAME)
49 {
50 $host = SITE_SERVER_NAME;
51 }
52 else
53 {
54 $host =
55 \Bitrix\Main\Config\Option::get('main', 'server_name', Context::getCurrent()->getServer()->getHttpHost())
56 ?: Context::getCurrent()->getServer()->getHttpHost()
57 ;
58 }
59
60 $port = Context::getCurrent()->getServer()->getServerPort();
61 if($port != 80 && $port != 443 && $port > 0 && mb_strpos($host, ':') === false)
62 {
63 $host .= ':'.$port;
64 }
65 elseif($protocol === 'http' && $port == 80)
66 {
67 $host = str_replace(':80', '', $host);
68 }
69 elseif($protocol === 'https' && $port == 443)
70 {
71 $host = str_replace(':443', '', $host);
72 }
73
74 return $protocol . '://' . $host;
75 }
76
77
78}
static getCurrent()
Definition context.php:241
__construct(string $providerId, Providers\OptionManager $optionManager)
Definition Registrar.php:14