Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
sectionbuilderfromdatamanager.php
1<?php
2
4
9use Bitrix\Calendar\Internals\EO_Section;
10
12{
16 private $sectionDM;
17
21 public function __construct(EO_Section $sectionDM)
22 {
23 $this->sectionDM = $sectionDM;
24 }
25
29 public function build(): Section
30 {
31 return (new Section())
32 ->setId($this->getId())
33 ->setName($this->getName())
34 ->setColor($this->getColor())
35 ->setGoogleId($this->getGoogleId())
36 ->setSyncToken($this->getSyncToken())
37 ->setPageToken($this->getPageToken())
38 ->setCalDavConnectionId($this->getCalDavConnectionId())
39 ->setDescription($this->getDescription())
40 ->setExternalType($this->getExternalType())
41 ->setType($this->getType())
42 ->setIsActive($this->getIsActive())
43 ->setXmlId($this->getXmlId())
44 ->setOwner($this->getOwner())
45 ->setCreator($this->getCreator())
46 ;
47 }
48
52 private function getId(): int
53 {
54 return $this->sectionDM->getId();
55 }
56
60 private function getGoogleId(): ?string
61 {
62 return $this->sectionDM->getGapiCalendarId();
63 }
64
68 private function getSyncToken(): ?string
69 {
70 return $this->sectionDM->getSyncToken();
71 }
72
76 private function getPageToken(): ?string
77 {
78 return $this->sectionDM->getPageToken();
79 }
80
84 private function getCalDavConnectionId(): ?int
85 {
86 return (int)$this->sectionDM->getCalDavCon() ?: null;
87 }
88
92 private function getDescription(): ?string
93 {
94 return $this->sectionDM->getDescription();
95 }
96
100 private function getName(): ?string
101 {
102 return $this->sectionDM->getName();
103 }
104
108 private function getColor(): string
109 {
110 return $this->sectionDM->getColor();
111 }
112
116 private function getExternalType(): string
117 {
118 return $this->sectionDM->getExternalType();
119 }
120
124 private function getIsActive(): bool
125 {
126 return $this->sectionDM->getActive();
127 }
128
132 private function getType(): string
133 {
134 return $this->sectionDM->getCalType();
135 }
136
140 private function getXmlId(): string
141 {
142 return $this->sectionDM->getXmlId();
143 }
144
150 private function getOwner(): ?Role
151 {
152 if ($id = $this->sectionDM->getOwnerId())
153 {
154 try
155 {
156 return Helper::getUserRole($id);
157 }
158 catch (BaseException $e)
159 {
160 return null;
161 }
162 }
163
164 return null;
165 }
166
172 private function getCreator(): ?Role
173 {
174 if ($id = ($this->sectionDM->getCreatedBy() ?? $this->sectionDM->getOwnerId()))
175 {
176 try
177 {
178 return Helper::getUserRole($id);
179 }
180 catch (BaseException $e)
181 {
182 return null;
183 }
184 }
185
186 return null;
187 }
188}