Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
eventlinkmapper.php
1<?php
3
5
7{
8 protected function convertToObject($objectEO): ?EventLink
9 {
10 $sharingEventLink = (new EventLink())
11 ->setId($objectEO->getId())
12 ->setEventId($objectEO->getObjectId())
13 ->setDateCreate($objectEO->getDateCreate())
14 ->setDateExpire($objectEO->getDateExpire())
15 ->setActive($objectEO->getActive())
16 ->setHash($objectEO->getHash())
17 ->setOwnerId($objectEO->getOwnerId())
18 ->setHostId($objectEO->getHostId())
19 ->setConferenceId($objectEO->getConferenceId())
20 ->setParentLinkHash($objectEO->getParentLinkHash())
21 ;
22
23 //backward compatibility
24 $options = $objectEO->getOptions();
25 if (!empty($options))
26 {
27 $options = Json::decode($options);
28 }
29 if (empty($sharingEventLink->getOwnerId()) && !empty($options['ownerId']))
30 {
31 $sharingEventLink->setOwnerId($options['ownerId']);
32 }
33 if (empty($sharingEventLink->getHostId()) && !empty($options['hostId']))
34 {
35 $sharingEventLink->setHostId($options['hostId']);
36 }
37 if (empty($sharingEventLink->getConferenceId()) && !empty($options['conferenceId']))
38 {
39 $sharingEventLink->setConferenceId($options['conferenceId']);
40 }
41 if (empty($sharingEventLink->getParentLinkHash()) && !empty($options['userLinkHash']))
42 {
43 $sharingEventLink->setParentLinkHash($options['userLinkHash']);
44 }
45 if (!empty($options['canceledTimestamp']))
46 {
47 $sharingEventLink->setCanceledTimestamp($options['canceledTimestamp']);
48 }
49
50 if (!empty($options['externalUserName']))
51 {
52 $sharingEventLink->setExternalUserName($options['externalUserName']);
53 }
54
55 return $sharingEventLink;
56 }
57
61 public function convertToArray($sharingLink): array
62 {
63 $baseArray = parent::convertToArray($sharingLink);
64
65 return array_merge($baseArray, [
66 'eventId' => $sharingLink->getEventId(),
67 'ownerId' => $sharingLink->getOwnerId(),
68 'hostId' => $sharingLink->getHostId(),
69 'conferenceId' => $sharingLink->getConferenceId(),
70 'parentLinkHash' => $sharingLink->getParentLinkHash(),
71 'canceledTimestamp' => $sharingLink->getCanceledTimestamp(),
72 'externalUserName' => $sharingLink->getExternalUserName(),
73 ]);
74 }
75
76 protected function getOptionsArray($entity): array
77 {
78 $options = [];
79
80 if (!empty($entity->getCanceledTimestamp()))
81 {
82 $options['canceledTimestamp'] = $entity->getCanceledTimestamp();
83 }
84
85 if (!empty($entity->getExternalUserName()))
86 {
87 $options['externalUserName'] = $entity->getExternalUserName();
88 }
89
90 return $options;
91 }
92
93 protected function getSpecificFields($entity): array
94 {
95 return [
96 'HOST_ID' => $entity->getHostId(),
97 'OWNER_ID' => $entity->getOwnerId(),
98 'CONFERENCE_ID' => $entity->getConferenceId(),
99 'PARENT_LINK_HASH' => $entity->getParentLinkHash(),
100 ];
101 }
102
103 protected function getEntityClass(): string
104 {
105 return EventLink::class;
106 }
107
108 protected function getEntityName(): string
109 {
110 return 'Calendar sharing user link';
111 }
112}