Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
eventbuilderfromgetlist.php
1<?php
2
4
15
17{
22 protected function getRecurringRule(): ?Event\Properties\RecurringEventRules
23 {
24 if (
25 isset($this->fields['RRULE'])
26 && isset($this->fields['RRULE']['FREQ'])
27 && $this->fields['RRULE']['FREQ'] !== 'NONE'
28 )
29 {
30 $rule = new Event\Properties\RecurringEventRules($this->fields['RRULE']['FREQ']);
31
32 if (isset($this->fields['RRULE']['COUNT']))
33 {
34 $rule->setCount((int)$this->fields['RRULE']['COUNT']);
35 }
36
37 if (is_string($this->fields['RRULE']['UNTIL']))
38 {
39 $rule->setUntil($this->createDateForRecurrence($this->fields['RRULE']['UNTIL']));
40 }
41
42 if (isset($this->fields['RRULE']['INTERVAL']))
43 {
44 $rule->setInterval((int)$this->fields['RRULE']['INTERVAL']);
45 }
46
47 if (
48 is_string($this->fields['RRULE']['BYDAY'])
49 && $this->fields['RRULE']['FREQ'] === Event\Properties\RecurringEventRules::FREQUENCY_WEEKLY
50 )
51 {
52 $rule->setByDay(explode(",", $this->fields['RRULE']['BYDAY']));
53 }
54 elseif (
55 is_array($this->fields['RRULE']['BYDAY'])
56 && $this->fields['RRULE']['FREQ'] === Event\Properties\RecurringEventRules::FREQUENCY_WEEKLY
57 )
58 {
59 $rule->setByDay($this->fields['RRULE']['BYDAY']);
60 }
61
62 return $rule;
63 }
64
65 return null;
66 }
67
71 protected function getLocation(): ?Event\Properties\Location
72 {
73 if (is_array($this->fields['LOCATION']) && isset($this->fields['LOCATION']['NEW']))
74 {
75 $location = new Event\Properties\Location($this->fields['NEW']);
76 if (isset($this->fields['LOCATION']['OLD']))
77 {
78 $location->setOriginalLocation($this->fields['LOCATION']['OLD']);
79 }
80
81 return $location;
82 }
83
84 if (is_string($this->fields['LOCATION']))
85 {
86 return new Event\Properties\Location($this->fields['LOCATION']);
87 }
88
89 return null;
90 }
91
97 protected function getStart(): Date
98 {
99 return new Date(
100 Util::getDateObject((is_object($this->fields['DATE_FROM'])
101 ? $this->fields['DATE_FROM']->format('d.m.y H:i:s')
102 : $this->fields['DATE_FROM']),
103 $this->fields['DT_SKIP_TIME'] === 'Y',
104 $this->fields['TZ_FROM'] ?? null)
105 );
106 }
107
113 protected function getEnd(): Date
114 {
115 return new Date(
116 Util::getDateObject((is_object($this->fields['DATE_TO'])
117 ? $this->fields['DATE_TO']->format('d.m.y H:i:s')
118 : $this->fields['DATE_TO']),
119 $this->fields['DT_SKIP_TIME'] === 'Y',
120 $this->fields['TZ_TO'] ?? null)
121 );
122 }
123
127 protected function getFullDay(): bool
128 {
129 return isset($this->fields['DT_SKIP_TIME']) && $this->fields['DT_SKIP_TIME'] === 'Y';
130 }
131
135 protected function getAttendees(): ?AttendeeCollection
136 {
137 $collection = new AttendeeCollection();
138
139 if (is_string($this->fields['ATTENDEES_CODES']))
140 {
141 $collection->setAttendeesCodes(explode(',', $this->fields['ATTENDEES_CODES']));
142 }
143 else if (is_array($this->fields['ATTENDEE_LIST']))
144 {
145 $collection->setAttendeesId(array_column($this->fields['ATTENDEE_LIST'], 'id'));
146 }
147 else
148 {
149 $collection->setAttendeesId([(int)$this->fields['OWNER_ID']]);
150 }
151
152
153 return $collection;
154 }
155
156// /**
157// * @return Event\Properties\RemindCollection|null
158// */
159// protected function getReminders(): Event\Properties\RemindCollection
160// {
161// if (!is_array($this->fields['REMIND']))
162// {
163// return new Event\Properties\RemindCollection();
164// }
165//
166// $collection = new Event\Properties\RemindCollection();
169// $collection->add((new Event\Properties\Remind())->setTimeBeforeEvent());
171//
172// return $collection;
173// }
174
181 protected function getSection(): Section
182 {
183 if (
184 isset($this->fields['SECTION_ID'])
185 && $sectionDM = SectionTable::getById($this->fields['SECTION_ID'])->fetchObject()
186 )
187 {
188 return (new SectionBuilderFromDataManager($sectionDM))->build();
189 }
190
191 throw new BuilderException('it is impossible to find the section');
192 }
193}
static getDateObject(string $date=null, ?bool $fullDay=true, ?string $tz='UTC')
Definition util.php:102