1C-Bitrix 25.700.0
Загрузка...
Поиск...
Не найдено
spaceeventprocessor.php
См. документацию.
1<?php
2
3namespace Bitrix\Socialnetwork\Internals\EventService\Processors;
4
5use Bitrix\Main\Config\Option;
6use Bitrix\Socialnetwork\Internals\EventService\Event;
7use Bitrix\Socialnetwork\Internals\EventService\EventCollection;
8use Bitrix\Socialnetwork\Internals\EventService\EventDictionary;
9use Bitrix\Socialnetwork\Internals\EventService\Queue\Queue;
10use Bitrix\Socialnetwork\Internals\EventService\Recepients\Recepient;
11use Bitrix\Socialnetwork\Internals\LiveFeed;
12use Bitrix\Socialnetwork\Internals\Space;
13use Bitrix\Socialnetwork\Space\List\RecentActivity;
14use Bitrix\Socialnetwork\Space\Role;
15
17{
18 private Queue $queue;
19 private Role\Event\Service $roleService;
20
21 public function __construct()
22 {
23 $this->queue = Queue::getInstance();
24 $this->roleService = new Role\Event\Service();
25 }
26
27 public function getStepLimit(): int
28 {
29 return (int) Option::get('socialnetwork', 'space_processor_step_limit', 100);
30 }
31
38 public function process(): void
39 {
40 $isSpaceFeatureDisabled = !(\Bitrix\Socialnetwork\Space\Service::isAvailable());
41 $isSpaceProcessorDisabled = Option::get('socialnetwork', 'space_processor_disabled', 'N') === 'Y';
42
43 if ($isSpaceFeatureDisabled)
44 {
45 return;
46 }
47
48 if ($isSpaceProcessorDisabled)
49 {
50 return;
51 }
52
53 foreach (EventCollection::getInstance()->list() as $event)
54 {
55 /* @var Event $event */
56 if (!in_array($event->getType(), EventDictionary::SPACE_EVENTS_SUPPORTED, true))
57 {
58 continue;
59 }
60
61 $this->processEvent($event);
62 }
63 }
64
65 public function processEventForUser(Event $event, Recepient $recipient): void
66 {
67 // recount live-feed counters in case event is one of the live-feeds'
69 // recount space counters and push events for real-time
70 (new Space\Counter\CounterController($recipient->getId()))->process($event, $recipient);
71 // save space recent activity
72 $this->roleService->processEvent($event, $recipient);
73 (new RecentActivity\Event\Service())->processEvent($event, $recipient);
74 }
75
76 private function processEvent(Event $event, int $offset = 0, bool $processInQueue = false): void
77 {
78 $limit = $this->getStepLimit();
79 $recipients = $event->getRecepients()->fetch($limit, $offset);
80
81 foreach ($recipients as $recipient)
82 {
83 if ($processInQueue)
84 {
85 $this->queue->add($event, $recipient);
86
87 continue;
88 }
89
90 $this->processEventForUser($event, $recipient);
91 }
92
93 $this->queue->save();
94
95 if (count($recipients) >= $limit)
96 {
97 $processInQueue = true;
98 $offset = $offset + $limit;
99 $this->processEvent($event, $offset, $processInQueue);
100 }
101 }
102}
static isAvailable(bool $isPublic=false)
Определения Service.php:9
$event
Определения prolog_after.php:141
</p ></td >< td valign=top style='border-top:none;border-left:none;border-bottom:solid windowtext 1.0pt;border-right:solid windowtext 1.0pt;padding:0cm 2.0pt 0cm 2.0pt;height:9.0pt'>< p class=Normal align=center style='margin:0cm;margin-bottom:.0001pt;text-align:center;line-height:normal'>< a name=ТекстовоеПоле54 ></a ><?=($taxRate > count( $arTaxList) > 0) ? $taxRate."%"
Определения waybill.php:936