Commit 826e821d authored by Stephane Bouvry's avatar Stephane Bouvry
Browse files

Fix : Suppression des activités (Erreur lors de la purge des notifications)

parent 3757e56b
Loading
Loading
Loading
Loading
Loading
+8 −0
Original line number Diff line number Diff line
@@ -121,6 +121,14 @@ class NotificationRepository extends EntityRepository
        return $qb->getQuery()->execute();
    }

    public function removeNotificationsActivity(int $activityId)
    {
        foreach ($this->getNotificationsActivity($activityId) as $notification) {
            $this->getEntityManager()->remove($notification);
        }
        $this->getEntityManager()->flush();
    }

    public function purgeAll()
    {
        $dql = 'DELETE ' . Notification::class;
+11 −0
Original line number Diff line number Diff line
@@ -862,6 +862,17 @@ class NotificationService implements UseServiceContainer
        return $this->getNotificationRepository()->deleteNotificationsPerson($person->getId());
    }

    public function deleteNotificationActivityById(int $activityId)
    {
        try {
            $this->getNotificationRepository()->removeNotificationsActivity($activityId);
        } catch (\Exception $e) {
            $this->getLoggerService()->err("Suppression des notifications pour l'activité '$activityId' : "
                                           . $e->getMessage());
        }
    }


    /**
     * @param $personId
     * @return array