1C-Bitrix 25.700.0
Загрузка...
Поиск...
Не найдено
sectionbuilderfromarray.php
См. документацию.
1<?php
2
3namespace Bitrix\Calendar\Core\Builders;
4
5use Bitrix\Calendar\Core\Base\BaseException;
6use Bitrix\Calendar\Core\Event\Tools\Dictionary;
7use Bitrix\Calendar\Core\Role\Helper;
8use Bitrix\Calendar\Core\Role\Role;
9use Bitrix\Calendar\Core\Section\Section;
10use Bitrix\Calendar\Integration\SocialNetwork\Collab;
11
13{
15 private $fields;
16
20 public function __construct(array $fields)
21 {
22 $this->fields = $fields;
23 }
24
31 public function build(): Section
32 {
33 return (new Section())
34 ->setId($this->getId())
35 ->setName($this->getName())
36 ->setColor($this->getColor())
37 ->setDescription($this->getDescription())
38 ->setGoogleId($this->getGoogleId())
39 ->setSyncToken($this->getSyncToken())
40 ->setCalDavConnectionId($this->getCalDavConnectionId())
41 ->setExternalType($this->getExternalType())
42 ->setType($this->getType())
43 ->setIsActive($this->getIsActive())
44 ->setXmlId($this->getXmlId())
45 ->setOwner($this->getOwner())
46 ->setCreator($this->getCreator())
47 ->setIsCollab($this->getIsCollab())
48 ;
49 }
50
54 private function getId(): int
55 {
56 return (int)($this->fields['ID'] ?? null);
57 }
58
62 private function getName(): ?string
63 {
64 return $this->fields['NAME'] ?? null;
65 }
66
70 private function getColor(): ?string
71 {
72 return $this->fields['COLOR'] ?? null;
73 }
74
78 private function getDescription(): ?string
79 {
80 return $this->fields['DESCRIPTION'] ?? null;
81 }
82
86 private function getGoogleId(): ?string
87 {
88 return $this->fields['GAPI_CALENDAR_ID'] ?? null;
89 }
90
94 private function getSyncToken(): ?string
95 {
96 return $this->fields['CAL_DAV_MOD'] ?? null;
97 }
98
102 private function getCalDavConnectionId(): ?int
103 {
104 return (int)$this->fields['CAL_DAV_CON'] ?: null;
105 }
106
110 private function getExternalType(): ?string
111 {
112 return $this->fields['EXTERNAL_TYPE'] ?? null;
113 }
114
118 private function getType(): ?string
119 {
120 return $this->fields['CAL_TYPE'] ?? null;
121 }
122
126 private function getIsActive(): bool
127 {
128 return ($this->fields['ACTIVE'] ?? null) === 'Y';
129 }
130
134 private function getXmlId(): ?string
135 {
136 return $this->fields['XML_ID'] ?? null;
137 }
138
144 private function getOwner(): ?Role
145 {
146 try
147 {
148 $ownerId = $this->fields['OWNER_ID'] ?? 0;
149
150 if (!$ownerId)
151 {
152 return null;
153 }
154
155 return match ($this->fields['CAL_TYPE'])
156 {
157 Dictionary::CALENDAR_TYPE['group'] => Helper::getGroupRole($ownerId),
158 Dictionary::CALENDAR_TYPE['company'] => Helper::getCompanyRole($ownerId),
159 default => Helper::getUserRole($ownerId),
160 };
161 }
162 catch (BaseException $e)
163 {
164 return null;
165 }
166 }
167
173 private function getCreator(): ?Role
174 {
175 try
176 {
177 return Helper::getUserRole($this->fields['CREATED_BY'] ?? 0);
178 }
179 catch (BaseException $e)
180 {
181 return null;
182 }
183 }
184
185 private function getIsCollab(): bool
186 {
187 if (array_key_exists('IS_COLLAB', $this->fields))
188 {
189 return $this->fields['IS_COLLAB'];
190 }
191
192 if (!$this->getId())
193 {
194 return false;
195 }
196
197 return (bool)Collab\Entity\SectionEntityHelper::getIfCollab($this->getId());
198 }
199}
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
Определения file_new.php:804