Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
jointlinkmapper.php
1<?php
2
4
13
14abstract class JointLinkMapper extends LinkMapper
15{
16 protected const DEFAULT_SELECT = ['*', 'MEMBERS'];
17 protected function createRelated($entity): void
18 {
19 if ($entity->isJoint())
20 {
21 $toAdd = [];
22 $linkId = $entity->getId();
23 $members = $entity->getMembers();
24 foreach ($members as $member)
25 {
26 $toAdd[] = [
27 'LINK_ID' => $linkId,
28 'MEMBER_ID' => $member->getId(),
29 ];
30 }
31 SharingLinkMemberTable::addMulti($toAdd, true);
32 }
33 }
34
35 protected function getDataManagerResult(array $params): Result
36 {
37 $params['select'] = static::DEFAULT_SELECT;
38
39 return SharingLinkTable::getList($params);
40 }
41
45 public function convertToArray($sharingLink): array
46 {
47 $baseArray = parent::convertToArray($sharingLink);
48
49 $members = array_map(static function($member) {
50 return $member->toArray();
51 }, $sharingLink->getMembers());
52
53 return array_merge($baseArray, [
54 'members' => $members,
55 'membersHash' => $sharingLink->getMembersHash(),
56 'userIds' => array_merge([$sharingLink->getOwnerId()], array_map(static fn ($member) => $member['id'], $members)),
57 'isJoint' => $sharingLink->isJoint(),
58 'shortUrl' => Helper::getShortUrl($sharingLink->getUrl()),
59 ]);
60 }
61
62 protected function deleteRelated(EntityInterface $entity): void
63 {
64 (new Rule\Mapper())->deleteLinkRule($entity->getId());
65 }
66}
static getShortUrl(string $url)
Definition helper.php:134
static getList(array $parameters=array())