Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
sectionbuilderfromarray.php
1<?php
2
4
9
11{
13 private $fields;
14
18 public function __construct(array $fields)
19 {
20 $this->fields = $fields;
21 }
22
29 public function build(): Section
30 {
31 return (new Section())
32 ->setId($this->getId())
33 ->setName($this->getName())
34 ->setColor($this->getColor())
35 ->setDescription($this->getDescription())
36 ->setGoogleId($this->getGoogleId())
37 ->setSyncToken($this->getSyncToken())
38 ->setCalDavConnectionId($this->getCalDavConnectionId())
39 ->setExternalType($this->getExternalType())
40 ->setType($this->getType())
41 ->setIsActive($this->getIsActive())
42 ->setXmlId($this->getXmlId())
43 ->setOwner($this->getOwner())
44 ->setCreator($this->getCreator())
45 ;
46 }
47
51 private function getId(): int
52 {
53 return (int)($this->fields['ID'] ?? null);
54 }
55
59 private function getName(): ?string
60 {
61 return $this->fields['NAME'] ?? null;
62 }
63
67 private function getColor(): ?string
68 {
69 return $this->fields['COLOR'] ?? null;
70 }
71
75 private function getDescription(): ?string
76 {
77 return $this->fields['DESCRIPTION'] ?? null;
78 }
79
83 private function getGoogleId(): ?string
84 {
85 return $this->fields['GAPI_CALENDAR_ID'] ?? null;
86 }
87
91 private function getSyncToken(): ?string
92 {
93 return $this->fields['CAL_DAV_MOD'] ?? null;
94 }
95
99 private function getCalDavConnectionId(): ?int
100 {
101 return (int)$this->fields['CAL_DAV_CON'] ?: null;
102 }
103
107 private function getExternalType(): ?string
108 {
109 return $this->fields['EXTERNAL_TYPE'] ?? null;
110 }
111
115 private function getType(): ?string
116 {
117 return $this->fields['CAL_TYPE'] ?? null;
118 }
119
123 private function getIsActive(): bool
124 {
125 return ($this->fields['ACTIVE'] ?? null) === 'Y';
126 }
127
131 private function getXmlId(): ?string
132 {
133 return $this->fields['XML_ID'] ?? null;
134 }
135
141 private function getOwner(): ?Role
142 {
143 try
144 {
145 return Helper::getUserRole($this->fields['OWNER_ID'] ?? 0);
146 }
147 catch (BaseException $e)
148 {
149 return null;
150 }
151 }
152
158 private function getCreator(): ?Role
159 {
160 try
161 {
162 return Helper::getUserRole($this->fields['CREATED_BY'] ?? 0);
163 }
164 catch (BaseException $e)
165 {
166 return null;
167 }
168 }
169}