17 private static ?
self $instance;
21 self::$instance ??=
new self();
23 return self::$instance;
26 public function onEventCreated(
int $eventId,
CreateEventCommand $createEventCommand,
int $threadId): void
29 $mapperFactory = ServiceLocator::getInstance()->get(
'calendar.service.mappers.factory');
30 $event = $mapperFactory->getEvent()->getById($eventId);
37 if (!$this->isOpenEvent(
$event))
42 $eventOption = $this->createEventOption(
48 $event->setEventOption($eventOption);
51 public function onEventEdited(
int $eventId, UpdateEventCommand $updateEventCommand): void
54 $mapperFactory = ServiceLocator::getInstance()->get(
'calendar.service.mappers.factory');
55 $event = $mapperFactory->getEvent()->getById($eventId);
61 if (!$this->isOpenEvent(
$event))
66 if ($updateEventCommand->getMaxAttendees() ===
null)
71 $eventOption =
$event->getEventOption();
72 $eventOption->setOptions(
new OptionsDto($updateEventCommand->getMaxAttendees()));
73 $mapperFactory->getEventOption()->update($eventOption);
76 private function createEventOption(
80 ?
int $maxAttendees = 0
84 $mapperFactory = ServiceLocator::getInstance()->get(
'calendar.service.mappers.factory');
85 $eventOption = (
new EventOptionBuilderFromArray([
86 'EVENT_ID' => $eventId,
87 'CATEGORY_ID' => $categoryId,
89 'max_attendees' => $maxAttendees ?? 0,
91 'THREAD_ID' => $threadId
93 $eventOptionFactory = $mapperFactory->getEventOption();
94 $eventOptionFactory->create($eventOption);
99 private function isOpenEvent(Event
$event): bool
101 $section =
$event->getSection();
103 return $section->getType() === Dictionary::CALENDAR_TYPE[
'open_event'];
106 private function __construct()