1C-Bitrix 25.700.0
Загрузка...
Поиск...
Не найдено
AbstractProcessor.php
См. документацию.
1<?php
2
4
12
13abstract class AbstractProcessor implements ProcessorInterface
14{
17
18 public function __construct(
19 protected Event $event,
20 protected Recepient $recipient,
21 )
22 {
23 $this->collector = new Collector(Collector::getDefaultProviders());
24 $this->activityService = new Service();
25 }
26
27 abstract protected function getTypeId(): string;
28 abstract protected function isAvailable(): bool;
29 abstract protected function process(): void;
30
31 protected function saveRecentActivityData(int $spaceId, int $entityId, ?int $secondaryEntityId = null): void
32 {
33 $recentActivityData =
34 (new RecentActivityData())
35 ->setSpaceId($spaceId)
36 ->setTypeId($this->getTypeId())
37 ->setEntityId($entityId)
38 ->setUserId($this->recipient->getId())
39 ->setDateTime($this->event->getDateTime())
40 ->setSecondaryEntityId($secondaryEntityId)
41 ;
42
43 $isSuccess = $this->activityService->save($recentActivityData);
44
45 if (!$isSuccess)
46 {
47 return;
48 }
49
50 $this->collector->addRecentActivityData($recentActivityData);
51 $this->collector->fillData();
52
53 $this->sendUpdatePush($recentActivityData);
54 }
55
56 protected function sendUpdatePush(RecentActivityData $recentActivityData): void
57 {
58 $this->sendPush(
59 PushEventDictionary::EVENT_SPACE_RECENT_ACTIVITY_UPDATE,
60 [$recentActivityData->toArray()]
61 );
62 }
63
64 private function sendPush(string $command, array $params): void
65 {
66 if ($this->recipient->isWatchingSpaces())
67 {
68 PushService::addEvent($this->recipient->getId(), [
69 'module_id' => PushService::MODULE_NAME,
70 'command' => $command,
71 'params' => $params,
72 ]);
73 }
74 }
75
76 protected function deleteRecentActivityData(int $entityId): void
77 {
78 $this->activityService->deleteByUserId($this->recipient->getId(), $this->getTypeId(), $entityId);
79 $this->sendDeletePush($entityId);
80 }
81
82 protected function sendDeletePush(int $entityId): void
83 {
84 $this->sendPush(PushEventDictionary::EVENT_SPACE_RECENT_ACTIVITY_DELETE, [
85 'typeId' => $this->getTypeId(),
86 'entityId' => $entityId,
87 ]);
88 }
89
90 final public function processEvent(): void
91 {
92 if (!$this->isAvailable())
93 {
94 return;
95 }
96
97 $this->process();
98 }
99}
__construct(protected Event $event, protected Recepient $recipient,)
Определения AbstractProcessor.php:18
saveRecentActivityData(int $spaceId, int $entityId, ?int $secondaryEntityId=null)
Определения AbstractProcessor.php:31
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
Определения file_new.php:804
$entityId
Определения payment.php:4
$event
Определения prolog_after.php:141
if($inWords) echo htmlspecialcharsbx(Number2Word_Rus(roundEx($totalVatSum $params['CURRENCY']
Определения template.php:799