Bitrix-D7
23.9
Загрузка...
Поиск...
Не найдено
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
}
Bitrix\Main\Search\MapBuilder\create
static create()
Definition
mapbuilder.php:25
Bitrix\Main\Security\Random
Definition
random.php:6
Bitrix\Seo\BusinessSuite\Catalog
Definition
catalog.php:14
Bitrix\Seo\BusinessSuite\Conversion
Definition
conversion.php:12
Bitrix\Seo\BusinessSuite\Extension
Definition
extension.php:9
Bitrix\Seo\BusinessSuite\ServiceAdapter
Definition
serviceadapter.php:10
Bitrix\Seo\BusinessSuite\ServiceAdapter\setWrapper
setWrapper(?ServiceWrapper $wrapper)
Definition
serviceadapter.php:105
Bitrix\Seo\BusinessSuite\ServiceAdapter\load
static load($type)
Definition
serviceadapter.php:70
Bitrix\Seo\BusinessSuite\ServiceAdapter\canUse
canUse()
Definition
serviceadapter.php:86
Bitrix\Seo\BusinessSuite\ServiceAdapter\loadFacebookService
static loadFacebookService()
Definition
serviceadapter.php:53
Bitrix\Seo\BusinessSuite\ServiceAdapter\$wrapper
$wrapper
Definition
serviceadapter.php:15
Bitrix\Seo\BusinessSuite\ServiceAdapter\getCatalog
getCatalog()
Definition
serviceadapter.php:158
Bitrix\Seo\BusinessSuite\ServiceAdapter\getConfig
getConfig()
Definition
serviceadapter.php:126
Bitrix\Seo\BusinessSuite\ServiceAdapter\createServiceWrapperContainer
static createServiceWrapperContainer()
Definition
serviceadapter.php:30
Bitrix\Seo\BusinessSuite\ServiceAdapter\getWrapper
getWrapper()
Definition
serviceadapter.php:115
Bitrix\Seo\BusinessSuite\ServiceAdapter\getExtension
getExtension()
Definition
serviceadapter.php:140
Bitrix\Seo\BusinessSuite\ServiceAdapter\getConversion
getConversion()
Definition
serviceadapter.php:153
Bitrix\Seo\BusinessSuite\Service\INSTAGRAM_TYPE
const INSTAGRAM_TYPE
Definition
service.php:13
Bitrix\Seo\BusinessSuite\Service\FACEBOOK_TYPE
const FACEBOOK_TYPE
Definition
service.php:12
Bitrix\Seo\BusinessSuite\ServiceWrapper
Definition
servicewrapper.php:11
Bitrix\Seo\BusinessSuite\Utils\ServicePool\getService
static getService($type)
Definition
servicepool.php:33
Bitrix\Seo\Retargeting\BaseApiObject\create
static create($type, $parameters=null, IService $service=null)
Definition
baseapiobject.php:61
Bitrix\Seo\Retargeting\BaseApiObject\setService
setService(IService $service)
Definition
baseapiobject.php:72
Bitrix\Main\Config
Definition
configuration.php:2
Bitrix\Seo\BusinessSuite\Utils
Definition
queueeventhandler.php:3
Bitrix\Seo\BusinessSuite
Definition
abstractbase.php:3
modules
seo
lib
businesssuite
serviceadapter.php
Создано системой
1.10.0