Skip to content

Commit 650e221

Browse files
author
tchapi
committed
Fix user deletion for shared calendars (again)
1 parent aa9f649 commit 650e221

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

src/Controller/Admin/UserController.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,10 @@ public function userDelete(ManagerRegistry $doctrine, string $username, Translat
155155
foreach ($instance->getCalendar()->getChanges() ?? [] as $change) {
156156
$entityManager->remove($change);
157157
}
158+
// We need to remove the shared versions of this calendar, too
159+
foreach ($instance->getCalendar()->getInstances() ?? [] as $instances) {
160+
$entityManager->remove($instances);
161+
}
158162
$entityManager->remove($instance->getCalendar());
159163
}
160164
$entityManager->remove($instance);

src/Entity/Calendar.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,9 @@ class Calendar
3131
#[ORM\OneToMany(targetEntity: "App\Entity\CalendarChange", mappedBy: 'calendar')]
3232
private $changes;
3333

34+
#[ORM\OneToMany(targetEntity: "App\Entity\CalendarInstance", mappedBy: 'calendar')]
35+
private $instances;
36+
3437
public function __construct()
3538
{
3639
$this->synctoken = 1;
@@ -129,4 +132,12 @@ public function removeChange(CalendarChange $change): self
129132

130133
return $this;
131134
}
135+
136+
/**
137+
* @return Collection|CalendarInstance[]
138+
*/
139+
public function getInstances(): Collection
140+
{
141+
return $this->instances;
142+
}
132143
}

0 commit comments

Comments
 (0)