Commit cf346213 authored by Stephane Bouvry's avatar Stephane Bouvry
Browse files

Fix : Suppression des activités (purge des notifications OK)

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

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

    public function purgeAll()
    {
        $dql = 'DELETE ' . Notification::class;
+10 −0
Original line number Diff line number Diff line
@@ -862,6 +862,16 @@ 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