Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
RichData.php
1<?php
2
4
6
7class RichData implements RestConvertible
8{
9 public const TASKS_TYPE = 'TASKS'; // rich data from tasks module
10 public const CALENDAR_TYPE = 'CALENDAR'; // rich data from calendar module
11 public const LANDING_TYPE = 'LANDING'; // rich data from landing module
12 public const POST_TYPE = 'POST'; // rich data from post from socialnetwork module
13 public const LINK_TYPE = 'LINK'; // rich data for non-dynamic url
14 public const DYNAMIC_TYPE = 'DYNAMIC'; // rich data for dynamic url without module
15
16 protected ?int $id = null;
17 protected ?string $type = null;
18 protected ?string $name = null;
19 protected ?string $description = null;
20 protected ?string $previewUrl = null;
21 protected ?string $link = null;
22 protected ?array $allowedUsers = null;
23
24 public static function initByAttach(?\CIMMessageParamAttach $attach): self
25 {
26 $rich = new static();
27
28 if ($attach === null)
29 {
30 return $rich;
31 }
32
33 $arrayAttach = $attach->GetArray();
34 $richLink = $arrayAttach['BLOCKS'][0]['RICH_LINK'][0];
35 $rich->setType(RichData::LINK_TYPE)
36 ->setDescription($richLink['DESC'])
37 ->setName($richLink['NAME'])
38 ->setPreviewUrl($richLink['PREVIEW'])
39 ;
40
41 return $rich;
42 }
43
44 //region Getters & setters
45
46 public function getId(): ?int
47 {
48 return $this->id;
49 }
50
51 public function setId(?int $id): RichData
52 {
53 $this->id = $id;
54 return $this;
55 }
56
57 public function getType(): ?string
58 {
59 return $this->type;
60 }
61
62 public function setType(?string $type): RichData
63 {
64 $this->type = $type;
65 return $this;
66 }
67
68 public function getName(): ?string
69 {
70 return $this->name;
71 }
72
73 public function setName(?string $name): RichData
74 {
75 $this->name = $name;
76 return $this;
77 }
78
79 public function getDescription(): ?string
80 {
81 return $this->description;
82 }
83
84 public function setDescription(?string $description): RichData
85 {
86 $this->description = $description;
87 return $this;
88 }
89
90 public function getPreviewUrl(): ?string
91 {
92 return $this->previewUrl;
93 }
94
95 public function setPreviewUrl(?string $previewUrl): RichData
96 {
97 $this->previewUrl = $previewUrl;
98 return $this;
99 }
100
101 public function getLink(): ?string
102 {
103 return $this->link;
104 }
105
106 public function setLink(?string $link): RichData
107 {
108 $this->link = $link;
109 return $this;
110 }
111
117 public function getAllowedUsers(): ?array
118 {
119 return $this->allowedUsers;
120 }
121
122 public function setAllowedUsers(array $allowedUsers): RichData
123 {
124 $this->allowedUsers = $allowedUsers;
125 return $this;
126 }
127
128 //endregion
129
130 public function toRestFormat(array $option = []): array
131 {
132 return [
133 'id' => $this->getId(),
134 'type' => $this->getType(),
135 'name' => $this->getName(),
136 'description' => $this->getDescription(),
137 'previewUrl' => $this->getPreviewUrl(),
138 'link' => $this->getLink(),
139 ];
140 }
141
142 public static function getRestEntityName(): string
143 {
144 return 'richData';
145 }
146}
setPreviewUrl(?string $previewUrl)
Definition RichData.php:95
toRestFormat(array $option=[])
Definition RichData.php:130
static initByAttach(?\CIMMessageParamAttach $attach)
Definition RichData.php:24
setDescription(?string $description)
Definition RichData.php:84
setAllowedUsers(array $allowedUsers)
Definition RichData.php:122