do not persist if no notification is scheduled

This commit is contained in:
Julien Fastré 2022-04-22 12:31:23 +02:00
parent 354f130e9e
commit 19561c63cb

View File

@ -46,10 +46,12 @@ class PersistNotificationOnTerminateEventSubscriber implements EventSubscriberIn
private function persistNotifications(): void private function persistNotifications(): void
{ {
foreach ($this->persister->getWaitingNotifications() as $notification) { if (0 < count($this->persister->getWaitingNotifications())) {
$this->em->persist($notification); foreach ($this->persister->getWaitingNotifications() as $notification) {
} $this->em->persist($notification);
}
$this->em->flush(); $this->em->flush();
}
} }
} }