Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
service.php
1<?php
3
8
9abstract class Service
10{
11 protected Event $event;
14 protected ?Event $oldEvent = null;
15 private ?array $owner = null;
16
20 public function getEvent(): Event
21 {
22 return $this->event;
23 }
24
29 public function setEvent(Event $event): self
30 {
31 $this->event = $event;
32
33 return $this;
34 }
35
39 public function getEventLink(): EventLink
40 {
41 return $this->eventLink;
42 }
43
48 public function setEventLink(EventLink $eventLink): self
49 {
50 $this->eventLink = $eventLink;
51
52 return $this;
53 }
54
59 public function setCrmDealLink(CrmDealLink $crmDealLink): self
60 {
61 $this->crmDealLink = $crmDealLink;
62
63 return $this;
64 }
65
70 public function setOldEvent(Event $oldEvent): self
71 {
72 $this->oldEvent = $oldEvent;
73
74 return $this;
75 }
76
80 protected function getEventFormattedDateTime(): string
81 {
82 $from = $this->event->getStart();
83 $to = $this->event->getEnd();
84 $isFullDay = $this->event->isFullDayEvent();
85 return Sharing\Helper::formatTimeInterval($from, $to, $isFullDay);
86 }
87
91 protected function getOwner(): array
92 {
93 if (is_array($this->owner))
94 {
95 return $this->owner;
96 }
97
98 $ownerId = $this->eventLink->getOwnerId();
99 $info = Sharing\Helper::getOwnerInfo($ownerId);
100 $ownerAttendee = current(array_filter($this->getAttendeesList(), static function($att) use ($ownerId) {
101 return $att['id'] === $ownerId;
102 }));
103
104 if (isset($ownerAttendee['status']) && !in_array($ownerAttendee['status'], ['Q', 'Y', 'N'], true))
105 {
106 $ownerAttendee['status'] = 'Q';
107 }
108
109 $this->owner = [
110 'ID' => $ownerId,
111 'NAME' => "{$info['name']} {$info['lastName']}",
112 'PHOTO' => $info['photo'],
113 'GENDER' => $info['gender'],
114 'STATUS' => $ownerAttendee['status'] ?? 'Q',
115 ];
116
117 return $this->owner;
118 }
119
123 protected function getCalendarLink(): ?string
124 {
125 if ($this->eventLink->getParentLinkHash())
126 {
127 $sharingLinkFactory = new Sharing\Link\Factory();
128 $userLink = $sharingLinkFactory->getLinkByHash($this->eventLink->getParentLinkHash());
129 if ($userLink)
130 {
131 return $userLink->getUrl();
132 }
133 }
134 return null;
135 }
136
140 protected function getAttendeesList(): array
141 {
142 return \CCalendarEvent::getAttendeeList($this->event->getId())['attendeeList'][$this->event->getId()];
143 }
144
150 abstract public function notifyAboutMeetingStatus(string $to): bool;
151
156 abstract public function notifyAboutSharingEventEdit(string $to): bool;
157}
setCrmDealLink(CrmDealLink $crmDealLink)
Definition service.php:59