Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
incominginvitationhandler.php
1<?php
2
3
5
6
9
11{
12 protected ?int $eventId = null;
13
14 abstract public function handle();
15
16 public function getEventId(): ?int
17 {
18 return $this->eventId;
19 }
20
21 protected function getAttendeesCollection(?array $parsedAttendees): AttendeesCollection
22 {
23 $attendeesCollection = AttendeesCollection::createInstance();
24
25 if (!is_null($parsedAttendees))
26 {
27 foreach($parsedAttendees as $attendee)
28 {
29 $participant = new Attendee();
30 $participant->setMailto(explode(':', $attendee['value']))[1];
31 $participant->setEmail($attendee['parameter']['email'] ?? $attendee->getMailTo());
32 $name = explode(" ", trim($attendee['parameter']['cn'], '"'), 2);
33 if (empty($name[0]))
34 {
35 $participant->setName($participant->getEmail());
36 }
37 else
38 {
39 $participant->setName($name[0]);
40 $participant->setLastName($name[1] ?? '');
41 }
42 $participant->setStatus($attendee['parameter']['partstat']);
43 $participant->setRole($attendee['parameter']['role']);
44 $participant->setCutype($attendee['parameter']['cutype']);
45
46 $attendeesCollection->add($participant);
47 }
48 }
49
50 return $attendeesCollection;
51 }
52
57 protected function getMailTo(?string $value): ?string
58 {
59 return mb_strpos($value, ':')
60 ? (explode(':', $value))[1]
61 : $value;
62 }
63}