1C-Bitrix 25.700.0
Загрузка...
Поиск...
Не найдено
crmdeallinkmapper.php
См. документацию.
1<?php
2
3namespace Bitrix\Calendar\Sharing\Link;
4
5use Bitrix\Calendar\Sharing\Link\Joint\JointLinkMapper;
6use Bitrix\Main\Web\Json;
7
9{
14 protected function getOptionsArray($entity): array
15 {
17 $options = [];
18
19 if (!empty($entity->getSlotSize()))
20 {
21 $options['slotSize'] = $entity->getSlotSize();
22 }
23
24 if (!empty($entity->getChannelId()))
25 {
26 $options['channelId'] = $entity->getChannelId();
27 }
28
29 if (!empty($entity->getSenderId()))
30 {
31 $options['senderId'] = $entity->getSenderId();
32 }
33
34 if (!empty($entity->getLastStatus()))
35 {
36 $options['lastStatus'] = $entity->getLastStatus();
37 }
38
39 return $options;
40 }
41
42 protected function getEntityClass(): string
43 {
44 return CrmDealLink::class;
45 }
46
47 protected function convertToObject($objectEO): ?CrmDealLink
48 {
49 $crmDealLink = (new CrmDealLink())
50 ->setId($objectEO->getId())
51 ->setEntityId($objectEO->getObjectId())
52 ->setDateCreate($objectEO->getDateCreate())
53 ->setDateExpire($objectEO->getDateExpire())
54 ->setActive($objectEO->getActive())
55 ->setHash($objectEO->getHash())
56 ->setContactId($objectEO->getContactId())
57 ->setContactType($objectEO->getContactType())
58 ->setOwnerId($objectEO->getOwnerId())
59 ->setMembersHash($objectEO->getMembersHash())
60 ->setFrequentUse($objectEO->getFrequentUse())
61 ;
62
63 if ($objectEO->getMembers()?->count() > 0)
64 {
65 $crmDealLink->setMembers((new Member\Manager())->createMembersFromEntityObject($objectEO->getMembers()));
66 }
67
68 $options = Json::decode($objectEO->getOptions() ?? '');
69 if (!empty($options['slotSize']))
70 {
71 $crmDealLink->setSlotSize($options['slotSize']);
72 }
73
74 if (!empty($options['channelId']))
75 {
76 $crmDealLink->setChannelId($options['channelId']);
77 }
78
79 if (!empty($options['senderId']))
80 {
81 $crmDealLink->setSenderId($options['senderId']);
82 }
83
84 if (!empty($options['lastStatus']))
85 {
86 $crmDealLink->setLastStatus($options['lastStatus']);
87 }
88 //backward compatibility
89 if (empty($crmDealLink->getContactId()) && !empty($options['contactId']))
90 {
91 $crmDealLink->setContactId($options['contactId']);
92 }
93 if (empty($crmDealLink->getContactType()) && !empty($options['contactType']))
94 {
95 $crmDealLink->setContactType($options['contactType']);
96 }
97 if (empty($crmDealLink->getOwnerId()) && !empty($options['ownerId']))
98 {
99 $crmDealLink->setOwnerId($options['ownerId']);
100 }
101
102 $rule = (new Rule\Factory())->getRuleBySharingLink($crmDealLink);
103 $crmDealLink->setSharingRule($rule);
104
105 return $crmDealLink;
106 }
107
111 public function convertToArray($sharingLink): array
112 {
113 $baseArray = parent::convertToArray($sharingLink);
114
115 return array_merge($baseArray, [
116 'slotSize' => $sharingLink->getSlotSize(),
117 'channelId' => $sharingLink->getChannelId(),
118 'senderId' => $sharingLink->getSenderId(),
119 'entityId' => $sharingLink->getEntityId(),
120 'contactId' => $sharingLink->getContactId(),
121 'contactType' => $sharingLink->getContactType(),
122 'ownerId' => $sharingLink->getOwnerId(),
123 'lastStatus' => $sharingLink->getLastStatus(),
124 'rule' => (new Rule\Mapper())->convertToArray($sharingLink->getSharingRule()),
125 ]);
126 }
127
128 protected function getSpecificFields($entity): array
129 {
130 return [
131 'OWNER_ID' => $entity->getOwnerId(),
132 'CONTACT_ID' => $entity->getContactId(),
133 'CONTACT_TYPE' => $entity->getContactType(),
134 'MEMBERS_HASH' => $entity->getMembersHash(),
135 ];
136 }
137
138 protected function getEntityName(): string
139 {
140 return 'Crm deal sharing link';
141 }
142}
$options
Определения commerceml2.php:49
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
Определения file_new.php:804
$entity