Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
conversion.php
1<?php
2
4
12
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
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}
addEvent(ConversionEventInterface $event)