feat(calendar): enhance iCalendar export functionality to use sabre#1584
Open
JohnVillalovos wants to merge 1 commit into
Open
feat(calendar): enhance iCalendar export functionality to use sabre#1584JohnVillalovos wants to merge 1 commit into
JohnVillalovos wants to merge 1 commit into
Conversation
removes template file for ical
Contributor
There was a problem hiding this comment.
Pull request overview
This PR migrates LibreBooking’s iCalendar (ICS) export from a Smarty template to programmatic generation using sabre/vobject, and removes the now-unused template. It also adjusts PHPStan configuration to accommodate Sabre’s magic-property access patterns.
Changes:
- Generate VCALENDAR/VEVENT/VALARM output in
CalendarExportDisplayusingSabre\VObjectinstead oftpl/Export/ical.tpl. - Remove the legacy ICS Smarty template file.
- Configure PHPStan to treat
Sabre\VObject\Nodeas a universal object crate to avoid pervasiveproperty.notFoundreports.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 5 comments.
| File | Description |
|---|---|
Pages/Export/CalendarExportDisplay.php |
Replaces template rendering with Sabre-based ICS construction (VEVENTs, alarms, extra lines). |
tpl/Export/ical.tpl |
Deleted legacy template that previously emitted raw ICS text. |
phpstan.neon |
Adds Sabre\VObject\Node to universalObjectCratesClasses for baseline analysis. |
phpstan_next.neon |
Mirrors the same PHPStan suppression for the “next” config. |
Comment on lines
+35
to
+56
| $isoFormat = 'Ymd\THis\Z'; | ||
|
|
||
| foreach ($reservations as $res) { | ||
| /** @var iCalendarReservationView $res */ | ||
| $event = new VEvent($vcal, 'VEVENT'); | ||
| $vcal->add($event); | ||
| // VEvent auto-generates UID and DTSTAMP in getDefaults(); use = to replace them. | ||
| $event->UID = $res->ReferenceNumber . '&' . $uid; | ||
| $event->DTSTAMP = $res->DateCreated->Format($isoFormat); | ||
| $event->add('CLASS', $res->Classification); | ||
| $event->add('CREATED', $res->DateCreated->Format($isoFormat)); | ||
| $event->add('DESCRIPTION', $res->Description); | ||
| $event->add('DTSTART', $res->DateStart->Format($isoFormat)); | ||
| $event->add('DTEND', $res->DateEnd->Format($isoFormat)); | ||
| $event->add('LAST-MODIFIED', $res->LastModified->Format($isoFormat)); | ||
| $event->add('LOCATION', $res->Location); | ||
| $event->add('ORGANIZER', 'mailto:' . $res->OrganizerEmail, ['CN' => $res->Organizer]); | ||
| $event->add('STATUS', $res->IsPending ? 'TENTATIVE' : 'CONFIRMED'); | ||
| $event->add('SUMMARY', $res->Summary); | ||
| $event->add('SEQUENCE', 0); | ||
| $event->add('URL', $res->ReservationUrl); | ||
| $event->add('X-MICROSOFT-CDO-BUSYSTATUS', 'BUSY'); |
Comment on lines
+65
to
+68
| if ($line !== '' && str_contains($line, ':')) { | ||
| [$prop, $val] = explode(':', $line, 2); | ||
| $event->add(trim($prop), $val); | ||
| } |
Comment on lines
+75
to
+78
| $alarm->add('TRIGGER', '-PT' . $res->StartReminder->MinutesPrior() . 'M', ['RELATED' => 'START']); | ||
| $alarm->add('ACTION', 'DISPLAY'); | ||
| $alarm->add('DESCRIPTION', $res->Description); | ||
| } |
Comment on lines
+83
to
+86
| $alarm->add('TRIGGER', '-PT' . $res->EndReminder->MinutesPrior() . 'M', ['RELATED' => 'END']); | ||
| $alarm->add('ACTION', 'DISPLAY'); | ||
| $alarm->add('DESCRIPTION', $res->Summary); | ||
| } |
| * @return string | ||
| */ | ||
| public function Render($reservations) | ||
| public function Render(array $reservations, ?string $calendarName = null): string |
Collaborator
Author
|
@lucs7 Can you look at this PR? It is the first commit from your PR. Feel free to make changes on your PR and I can update this one. Or if you want create a new PR with just this one commit. Thanks! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
removes template file for ical