Skip to content

Commit 66f929d

Browse files
author
tchapi
committed
chore
1 parent 4860e97 commit 66f929d

2 files changed

Lines changed: 8 additions & 2 deletions

File tree

config/services.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ services:
7777
App\Services\BirthdayService:
7878
arguments:
7979
$birthdayReminderOffset: "%birthday_reminder_offset%"
80+
$calendarBackend: null # will be overridden when instantiated manually
8081

8182
App\Security\ApiKeyAuthenticator:
8283
arguments:

src/Services/BirthdayService.php

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@
1919
use App\Entity\Card;
2020
use App\Entity\Principal;
2121
use Doctrine\Persistence\ManagerRegistry;
22-
use Sabre\DAV\Sharing\Plugin as SharingPlugin;
2322
use Sabre\CalDAV\Backend\PDO as CalendarBackend;
23+
use Sabre\DAV\Sharing\Plugin as SharingPlugin;
2424
use Sabre\VObject\Component\VCalendar;
2525
use Sabre\VObject\Component\VCard;
2626
use Sabre\VObject\DateTimeParser;
@@ -34,8 +34,13 @@ class BirthdayService
3434
public function __construct(
3535
private ManagerRegistry $doctrine,
3636
private string $birthdayReminderOffset,
37-
private CalendarBackend $calendarBackend,
37+
private ?CalendarBackend $calendarBackend = null,
3838
) {
39+
if (!$calendarBackend) {
40+
$em = $this->doctrine->getManager();
41+
$pdo = $em->getConnection()->getNativeConnection();
42+
$this->calendarBackend = new CalendarBackend($pdo);
43+
}
3944
}
4045

4146
public function onCardChanged(int $addressBookId, string $cardUri, string $cardData): void

0 commit comments

Comments
 (0)