Release: CalDAV sync bundle hardening and LMW sync

This commit is contained in:
Jürgen Mummert
2026-03-27 22:16:48 +01:00
commit c6f63a56a9
36 changed files with 2993 additions and 0 deletions
+56
View File
@@ -0,0 +1,56 @@
<?php
declare(strict_types=1);
namespace Mummert\CalDavSyncBundle\Config;
final readonly class CalendarSyncConfig
{
/**
* @param list<string> $selectedCalendarUrls
*/
public function __construct(
public int $calendarId,
public string $caldavUrl,
public string $caldavUsername,
public string $caldavPassword,
public int $caldavAuthorId,
public string $caldavTimezone,
public array $selectedCalendarUrls,
) {
}
public function timezoneOrDefault(): string
{
return '' !== trim($this->caldavTimezone) ? $this->caldavTimezone : 'UTC';
}
public function hasMultipleRemoteCalendars(): bool
{
return count($this->selectedCalendarUrls) > 1;
}
public function shouldManageEventForThisRemoteCalendar(string $eventCalendarUrl): bool
{
$normalizedEventUrl = trim($eventCalendarUrl);
if ('' === $normalizedEventUrl) {
return !$this->hasMultipleRemoteCalendars();
}
return $normalizedEventUrl === $this->caldavUrl;
}
public function resolveTargetCalendarForLocalEvent(string $eventCalendarUrl): ?string
{
$normalizedEventUrl = trim($eventCalendarUrl);
if ('' !== $normalizedEventUrl) {
return $normalizedEventUrl;
}
if ([] === $this->selectedCalendarUrls) {
return null;
}
return $this->selectedCalendarUrls[0];
}
}