Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
service.php
1<?
2
4
7
9{
10 const GROUP = 'retargeting';
11
12 const TYPE_FACEBOOK = 'facebook';
13 const TYPE_VKONTAKTE = 'vkontakte';
14 const TYPE_MYCOM = 'mycom';
15 const TYPE_YANDEX = 'yandex';
16 const TYPE_GOOGLE = 'google';
17
18 protected $clientId;
19
25 public static function getInstance(): Service
26 {
27 static $instance = null;
28 if ($instance === null)
29 {
30 $instance = new static();
31 }
32
33 return $instance;
34 }
35
40 public static function getEngineCode($type)
41 {
42 return static::GROUP . '.' . $type;
43 }
44
49 public static function getAudience($type)
50 {
51 return Audience::create($type)->setService(static::getInstance());
52 }
53
58 public static function getAccount($type)
59 {
60 return Account::create($type)->setService(static::getInstance());
61 }
62
69 public static function canUseMultipleClients()
70 {
71 return Option::get('seo', 'use_multiple_clients', true);
72 }
73
77 public static function getTypes()
78 {
79 return array(
80 static::TYPE_FACEBOOK,
81 static::TYPE_VKONTAKTE,
82 static::TYPE_GOOGLE,
83 static::TYPE_YANDEX
84 );
85 }
86
93 public static function getAuthAdapter($type)
94 {
95 return AuthAdapter::create($type)->setService(static::getInstance());
96 }
101 public function getClientId()
102 {
103 return $this->clientId;
104 }
110 public function setClientId($clientId)
111 {
112 $this->clientId = $clientId;
113 }
114
118 public static function getTypeByEngine(string $engineCode): ?string
119 {
120 foreach (static::getTypes() as $type)
121 {
122 if($engineCode === static::getEngineCode($type))
123 {
124 return $type;
125 }
126 }
127 return null;
128 }
132 public static function canUseAsInternal(): bool
133 {
134 return true;
135 }
136
140 public static function getMethodPrefix(): string
141 {
142 return 'retargeting';
143 }
144}
static getTypeByEngine(string $engineCode)
Definition service.php:118