1C-Bitrix 25.700.0
Загрузка...
Поиск...
Не найдено
eventmanager.php
См. документацию.
1<?php
2
3namespace Bitrix\Calendar\Internals\EventManager;
4
5use Bitrix\Main\Event;
6
7final class EventManager implements EventManagerInterface
8{
9 private array $handlers = [];
10
11 public function addEventHandler($fromModuleId, $eventType, $callback, $includeFile = false, $sort = 100)
12 {
13 $this->handlers[$eventType][] = ['callback' => $callback, 'sort' => $sort];
14 }
15
16 public function send(Event $event): void
17 {
18 $handlers = $this->getEventHandlers($event->getEventType());
19 usort($handlers, static fn ($h1, $h2) => $h1['sort'] <=> $h2['sort']);
20 foreach ($handlers as $handler)
21 {
22 $this->sendToEventHandler($handler['callback'], $event);
23 }
24 }
25
26 private function getEventHandlers(string $eventType): array
27 {
28 return $this->handlers[$eventType];
29 }
30
31 private function sendToEventHandler(callable $handler, Event $event): void
32 {
33 try
34 {
35 $result = call_user_func($handler, $event);
36
37 if ($result != null)
38 {
39 $event->addResult($result);
40 }
41 }
42 catch (\Throwable $e)
43 {
44 throw $e;
45 }
46 }
47}
addEventHandler($fromModuleId, $eventType, $callback, $includeFile=false, $sort=100)
Определения eventmanager.php:11
Определения event.php:5
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
Определения file_new.php:804
$result
Определения get_property_values.php:14
$event
Определения prolog_after.php:141