1C-Bitrix 25.700.0
Загрузка...
Поиск...
Не найдено
counterservice.php
См. документацию.
1<?php
2
3namespace Bitrix\Calendar\Internals\Counter;
4
5use Bitrix\Main\Application;
6use Bitrix\Calendar\Internals\Counter\Event\EventCollection;
7
9{
10 private static $instance;
11 private static $jobOn = false;
12 private static $hitId;
13
17 private function __construct()
18 {
19 self::$hitId = $this->generateHid();
20 $this->enableJob();
21 }
22
26 public static function getInstance(): CounterService
27 {
28 if (!self::$instance)
29 {
30 self::$instance = new self();
31 }
32
33 return self::$instance;
34 }
35
40 public static function addEvent(string $type, array $data): void
41 {
42 self::getInstance()->storeEvent($type, $data);
43 }
44
45 public static function proceedEvents(): void
46 {
47 $events = EventCollection::getInstance()->list();
48 if (empty($events))
49 {
50 return;
51 }
52
53 (new Processor\OpenEvent())->process();
54 (new Processor\Invite())->process();
55 (new Processor\GroupInvite())->process();
56 (new Processor\Sync())->process();
57 (new Processor\Total())->process();
58 }
59
64 private function storeEvent(string $type, array $data): void
65 {
66 $event = new Event\Event(self::$hitId, $type);
67 $event->setData($data);
68
69 $this->getEventCollection()->push($event);
70 }
71
72 private function enableJob(): void
73 {
74 if (self::$jobOn)
75 {
76 return;
77 }
78
79 $application = Application::getInstance();
80 $application && $application->addBackgroundJob(
81 [self::class, 'proceedEvents'],
82 [],
83 Application::JOB_PRIORITY_LOW - 2,
84 );
85
86 self::$jobOn = true;
87 }
88
92 private function getEventCollection(): EventCollection
93 {
95 }
96
100 private function generateHid(): string
101 {
102 return sha1(microtime(true) . mt_rand(10000, 99999));
103 }
104}
$type
Определения options.php:106
static addEvent(string $type, array $data)
Определения counterservice.php:40
$data['IS_AVAILABLE']
Определения .description.php:13
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
Определения file_new.php:804
$application
Определения bitrix.php:23
$event
Определения prolog_after.php:141