1C-Bitrix
25.700.0
Загрузка...
Поиск...
Не найдено
serviceadapter.php
См. документацию.
1
<?php
2
3
namespace
Bitrix\Seo\BusinessSuite;
4
5
6
use Bitrix\Main\Security\Random;
7
use Bitrix\Seo\BusinessSuite\Utils;
8
9
class
ServiceAdapter
10
{
11
private
const
CLASS_PREFIX =
'generatedWrapper'
;
12
private
const
CLASS_KEY_LENGTH = 16;
13
15
protected
$wrapper
;
16
21
private
static
function
generateServiceWrapperContainerName() : string
22
{
23
return
static::CLASS_PREFIX . Random::getStringByAlphabet(static::CLASS_KEY_LENGTH, Random::ALPHABET_ALPHALOWER);
24
}
25
30
public
final
static
function
createServiceWrapperContainer
() :
ServiceWrapper
31
{
32
while
($serviceWrapperClassName = static::generateServiceWrapperContainerName())
33
{
34
if
(!class_exists($serviceWrapperClassName,
false
))
35
{
36
eval(
"
37
class $serviceWrapperClassName extends Bitrix\Seo\BusinessSuite\ServiceWrapper
38
implements
39
Bitrix\Seo\Retargeting\IService,
40
Bitrix\Seo\Retargeting\IMultiClientService,
41
Bitrix\Seo\BusinessSuite\IInternalService
42
{}
43
"
);
44
return
$serviceWrapperClassName::getInstance();
45
}
46
}
47
}
48
53
public
static
function
loadFacebookService
(): ?
ServiceAdapter
54
{
55
if
($serviceWrapper =
Utils
\
ServicePool::getService
([
Service::INSTAGRAM_TYPE
,
Service::FACEBOOK_TYPE
]))
56
{
57
58
return
(
new
static
())->setWrapper($serviceWrapper);
59
}
60
61
return
null
;
62
}
63
70
public
static
function
load
(
$type
): ?
ServiceAdapter
71
{
72
if
($serviceWrapper =
Utils
\
ServicePool::getService
(
$type
))
73
{
74
75
return
(
new
static
())->setWrapper($serviceWrapper);
76
}
77
78
return
null
;
79
}
80
86
public
function
canUse
() : bool
87
{
88
if
(isset($this->wrapper))
89
{
90
91
return
$this->
getWrapper
()::getAuthAdapter($this->wrapper->getMetaData()->getType())->hasAuth();
92
}
93
94
return
false
;
95
}
96
105
public
function
setWrapper
(?
ServiceWrapper
$wrapper
):
ServiceAdapter
106
{
107
$this->wrapper =
$wrapper
;
108
return
$this;
109
}
110
115
public
function
getWrapper
() : ?
ServiceWrapper
116
{
117
return
$this->wrapper
;
118
}
119
126
public
function
getConfig
() : ?
Config
127
{
128
if
($this->
canUse
())
129
{
130
return
Config::create
($this->wrapper->getMetaData()->getType())->setService($this->wrapper);
131
}
132
return
null
;
133
}
134
140
public
function
getExtension
() : ?
Extension
141
{
142
if
($this->
canUse
())
143
{
144
return
Extension::create
($this->wrapper->getMetaData()->getType())->setService($this->wrapper);
145
}
146
return
null
;
147
}
148
153
public
function
getConversion
():
Conversion
154
{
155
return
Conversion::create
($this->wrapper->getMetaData()->getType())->setService($this->wrapper);
156
}
157
158
public
function
getCatalog
(): ?
Catalog
159
{
160
if
(!$this->
canUse
())
161
{
162
return
null
;
163
}
164
165
$metaData = $this->wrapper->getMetaData();
166
if
(!$metaData || !$metaData->getType())
167
{
168
return
null
;
169
}
170
171
return
Catalog::create
($metaData->getType())->setService($this->wrapper);
172
}
173
}
$type
$type
Определения
options.php:106
Bitrix\Main\IO\DirectoryEntry\create
create()
Определения
directoryentry.php:12
Bitrix\Seo\BusinessSuite\Extension
Определения
extension.php:9
Bitrix\Seo\BusinessSuite\ServiceAdapter
Определения
serviceadapter.php:10
Bitrix\Seo\BusinessSuite\ServiceAdapter\setWrapper
setWrapper(?ServiceWrapper $wrapper)
Определения
serviceadapter.php:105
Bitrix\Seo\BusinessSuite\ServiceAdapter\load
static load($type)
Определения
serviceadapter.php:70
Bitrix\Seo\BusinessSuite\ServiceAdapter\canUse
canUse()
Определения
serviceadapter.php:86
Bitrix\Seo\BusinessSuite\ServiceAdapter\loadFacebookService
static loadFacebookService()
Определения
serviceadapter.php:53
Bitrix\Seo\BusinessSuite\ServiceAdapter\getCatalog
getCatalog()
Определения
serviceadapter.php:158
Bitrix\Seo\BusinessSuite\ServiceAdapter\getConfig
getConfig()
Определения
serviceadapter.php:126
Bitrix\Seo\BusinessSuite\ServiceAdapter\createServiceWrapperContainer
static createServiceWrapperContainer()
Определения
serviceadapter.php:30
Bitrix\Seo\BusinessSuite\ServiceAdapter\getWrapper
getWrapper()
Определения
serviceadapter.php:115
Bitrix\Seo\BusinessSuite\ServiceAdapter\$wrapper
$wrapper
Определения
serviceadapter.php:15
Bitrix\Seo\BusinessSuite\ServiceAdapter\getExtension
getExtension()
Определения
serviceadapter.php:140
Bitrix\Seo\BusinessSuite\ServiceAdapter\getConversion
getConversion()
Определения
serviceadapter.php:153
Bitrix\Seo\BusinessSuite\Service\INSTAGRAM_TYPE
const INSTAGRAM_TYPE
Определения
service.php:13
Bitrix\Seo\BusinessSuite\Service\FACEBOOK_TYPE
const FACEBOOK_TYPE
Определения
service.php:12
Bitrix\Seo\BusinessSuite\ServiceWrapper
Определения
servicewrapper.php:11
Bitrix\Seo\BusinessSuite\Utils\ServicePool\getService
static getService($type)
Определения
servicepool.php:33
Bitrix\Seo\Retargeting\BaseApiObject\create
static create($type, $parameters=null, IService $service=null)
Определения
baseapiobject.php:61
Bitrix\Main\Config
Определения
configuration.php:3
Bitrix\Seo\BusinessSuite\Utils
Определения
queueeventhandler.php:3
Bitrix\Seo\Catalog
Определения
catalog.php:3
Bitrix\Seo\Conversion
Определения
conversioneventinterface.php:3
bitrix
modules
seo
lib
businesssuite
serviceadapter.php
Создано системой
1.14.0