1C-Bitrix 25.700.0
Загрузка...
Поиск...
Не найдено
service.php
См. документацию.
1<?php
2
3namespace Bitrix\Seo\LeadAds;
4
5use Bitrix\Seo\BusinessSuite\IInternalService;
6use Bitrix\Seo\Retargeting\AuthAdapter;
7use Bitrix\Seo\Retargeting\IService;
8
15{
16 public const GROUP = 'leadads';
17
18 public const TYPE_FACEBOOK = 'facebook';
19
20 public const TYPE_VKONTAKTE = 'vkontakte';
21
23 protected $accounts = [];
24
26 protected $forms = [];
27
36 public static function registerGroup(string $type, string $groupId): bool
37 {
38 return Form::create($type)
39 ->setService(static::getInstance())
40 ->registerGroup($groupId);
41 }
42
48 public static function getInstance(): Service
49 {
50 static $instance;
51
52 return $instance = $instance ?? new static();
53 }
54
63 public static function unRegisterGroup(string $type, string $groupId): bool
64 {
66 ->setService(static::getInstance())
67 ->unRegisterGroup($groupId);
68
69 static::getInstance()->getGroupAuth($type)->removeAuth();
70
71 return $result;
72 }
73
80 public static function getAuthAdapter($type): AuthAdapter
81 {
83 static $adapters;
84
85 $adapters = $adapters ?? [];
86 if (!array_key_exists($type, $adapters))
87 {
88 $adapters[$type] = AuthAdapter::create($type)->setService(static::getInstance());
89 }
90
91 return $adapters[$type];
92 }
93
97 public static function getTypeByEngine(string $engineCode): ?string
98 {
99 foreach (static::getTypes() as $type)
100 {
101 if ($engineCode === static::getEngineCode($type))
102 {
103 return $type;
104 }
105 }
106
107 return null;
108 }
109
115 public static function getTypes(): array
116 {
117 return [
118 static::TYPE_FACEBOOK,
119 static::TYPE_VKONTAKTE,
120 ];
121 }
122
129 public static function getEngineCode($type): string
130 {
131 return static::GROUP . '.' . $type;
132 }
133
137 public static function canUseAsInternal(): bool
138 {
139 return true;
140 }
141
145 public static function getMethodPrefix(): string
146 {
147 return 'leadads';
148 }
149
157 public function getGroupAuth(string $type): ?AuthAdapter
158 {
159 return $this->getForm($type)->getGroupAuthAdapter();
160 }
161
169 public function getForm(string $type): Form
170 {
171 if (!array_key_exists($type, $this->forms))
172 {
173 $this->forms[$type] = Form::create($type)->setService($this);
174 }
175
176 return $this->forms[$type];
177 }
178
186 public function getAccount(string $type): ?Account
187 {
188 if (!array_key_exists($type, $this->accounts))
189 {
190 $this->accounts[$type] = Account::create($type)->setService($this);
191 }
192
193 return $this->accounts[$type];
194 }
195
196 public function getAuthUrl($type): string
197 {
198 $authManager = static::getAuthAdapter($type);
199 return $authManager->getAuthUrl();
200 }
201}
202
$type
Определения options.php:106
Определения form.php:13
const TYPE_VKONTAKTE
Определения service.php:20
static getTypes()
Определения service.php:115
static getEngineCode($type)
Определения service.php:129
static unRegisterGroup(string $type, string $groupId)
Определения service.php:63
static registerGroup(string $type, string $groupId)
Определения service.php:36
getForm(string $type)
Определения service.php:169
static getTypeByEngine(string $engineCode)
Определения service.php:97
getAuthUrl($type)
Определения service.php:196
static getMethodPrefix()
Определения service.php:145
static canUseAsInternal()
Определения service.php:137
getGroupAuth(string $type)
Определения service.php:157
getAccount(string $type)
Определения service.php:186
static getInstance()
Определения service.php:48
const GROUP
Определения service.php:16
const TYPE_FACEBOOK
Определения service.php:18
static create($type, $parameters=null, IService $service=null)
Определения baseapiobject.php:61
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
Определения file_new.php:804
$result
Определения get_property_values.php:14
$instance
Определения ps_b24_final.php:14