Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
service.php
1<?php
2
4
5
8
10{
11 public const GROUP = 'business';
12 public const FACEBOOK_TYPE = "facebook";
13 public const INSTAGRAM_TYPE = 'instagram';
14
16 private static $authAdapterPool = [];
17
18 private function __construct()
19 {}
20
21 private function __clone()
22 {}
23
27 public static function getMethodPrefix() : string
28 {
29 return 'business';
30 }
31
37 public function getConfig(string $type): Config
38 {
39 return Config::create($type)->setService($this);
40 }
41
47 public function getExtension(string $type) : Extension
48 {
49 return Extension::create($type)->setService($this);
50 }
51
57 public function getConversion(string $type) : Conversion
58 {
59 return Conversion::create($type)->setService($this);
60 }
61
67 public function getAccount(string $type) : Account
68 {
69 return Account::create($type)->setService($this);
70 }
71
75 public static function getInstance(): self
76 {
77 static $instance;
78 if (!$instance)
79 {
80 $instance = new self();
81 }
82
83 return $instance;
84 }
85
91 public static function getEngineCode($type): string
92 {
93 return self::GROUP.'.'.$type;
94 }
95
99 public static function getTypes(): array
100 {
101 return [self::FACEBOOK_TYPE, self::INSTAGRAM_TYPE];
102 }
103
110 public static function getAuthAdapter($type) : BusinessAuthAdapter
111 {
112 if (!array_key_exists($type,static::$authAdapterPool))
113 {
114 static::$authAdapterPool[$type] = BusinessAuthAdapter::create($type)->setService(static::getInstance());
115 }
116
117 return static::$authAdapterPool[$type];
118 }
119
123 public static function getTypeByEngine(string $engineCode): ?string
124 {
125 foreach (static::getTypes() as $type)
126 {
127 if($engineCode == static::getEngineCode($type))
128 {
129
130 return $type;
131 }
132 }
133
134 return null;
135 }
136
140 public static function canUseAsInternal(): bool
141 {
142 return true;
143 }
144}
static getTypeByEngine(string $engineCode)
Definition service.php:123