Bitrix-D7
23.9
Загрузка...
Поиск...
Не найдено
conversion.php
1
<?php
2
3
namespace
Bitrix\Seo\Conversion\Facebook
;
4
5
use
Bitrix\Main\DI\ServiceLocator
;
6
use
Bitrix\Main\ObjectNotFoundException
;
7
use
Bitrix\Main\SystemException
;
8
use
Bitrix\Seo\BusinessSuite\DTO\Profile
;
9
use
Bitrix\Seo\BusinessSuite\Service
;
10
use
Bitrix\Seo\Conversion\ConversionEventInterface
;
11
use
Bitrix\Seo\Conversion\ConversionObjectInterface
;
12
13
final
class
Conversion
implements
ConversionObjectInterface
14
{
15
public
const
TYPE
=
'facebook'
;
16
18
private
$events = [];
19
21
private
$service;
22
29
public
function
__construct
(?
Service
$service)
30
{
31
$this->service = $service;
32
}
33
41
public
function
addEvent
(
ConversionEventInterface
$event):
ConversionObjectInterface
42
{
43
$this->events[] = $event;
44
45
return
$this;
46
}
47
51
public
function
getEvents
(): array
52
{
53
return
$this->events;
54
}
55
61
public
function
fireEvents
(): bool
62
{
63
if
($this->
isAvailable
())
64
{
65
if
(!empty($this->events))
66
{
67
$response = $this->service->getConversion($this->
getType
())->fireEvents($this->events);
68
if
($response && $response->isSuccess())
69
{
70
$this->events = [];
71
72
return
true
;
73
}
74
}
75
}
76
77
return
false
;
78
}
79
83
public
function
isAvailable
(): bool
84
{
85
86
return
$this->service && $this->service::getAuthAdapter($this->
getType
())->hasAuth();
87
}
88
92
public
function
getType
(): string
93
{
94
return
static::TYPE;
95
}
96
}
Bitrix\Main\DI\ServiceLocator
Definition
servicelocator.php:12
Bitrix\Main\ObjectNotFoundException
Definition
exception.php:203
Bitrix\Main\SystemException
Definition
exception.php:8
Bitrix\Seo\BusinessSuite\DTO\Profile
Definition
profile.php:6
Bitrix\Seo\BusinessSuite\Service
Definition
service.php:10
Bitrix\Seo\Conversion\Facebook\Conversion
Definition
conversion.php:14
Bitrix\Seo\Conversion\Facebook\Conversion\addEvent
addEvent(ConversionEventInterface $event)
Definition
conversion.php:41
Bitrix\Seo\Conversion\Facebook\Conversion\__construct
__construct(?Service $service)
Definition
conversion.php:29
Bitrix\Seo\Conversion\Facebook\Conversion\fireEvents
fireEvents()
Definition
conversion.php:61
Bitrix\Seo\Conversion\Facebook\Conversion\getEvents
getEvents()
Definition
conversion.php:51
Bitrix\Seo\Conversion\Facebook\Conversion\getType
getType()
Definition
conversion.php:92
Bitrix\Seo\Conversion\Facebook\Conversion\TYPE
const TYPE
Definition
conversion.php:15
Bitrix\Seo\Conversion\Facebook\Conversion\isAvailable
isAvailable()
Definition
conversion.php:83
Bitrix\Seo\Conversion\ConversionEventInterface
Definition
conversioneventinterface.php:6
Bitrix\Seo\Conversion\ConversionObjectInterface
Definition
conversionobjectinterface.php:6
Bitrix\Seo\Conversion\Facebook
Definition
conversion.php:3
modules
seo
lib
conversion
facebook
conversion.php
Создано системой
1.10.0