Make eventdb optional

This commit is contained in:
Alma Armas 2020-08-20 09:03:45 +00:00
parent 512f21c1a8
commit efef446220

View file

@ -47,7 +47,7 @@ class Notifications
{ {
$db = $this->getEDB(false); $db = $this->getEDB(false);
if(!$db) if(!$db)
return 1; return 0;
$results = $db->query($this->getQuery($user, true, $offset, $archived)); $results = $db->query($this->getQuery($user, true, $offset, $archived));
@ -56,6 +56,12 @@ class Notifications
function getNotificationsByUser(User $user, int $offset, bool $archived = false, int $page = 1, ?int $perPage = NULL): \Traversable function getNotificationsByUser(User $user, int $offset, bool $archived = false, int $page = 1, ?int $perPage = NULL): \Traversable
{ {
$db = $this->getEDB(false);
if(!$db) {
yield from [];
return;
}
$results = $this->getEDB()->query($this->getQuery($user, false, $offset, $archived, $page, $perPage)); $results = $this->getEDB()->query($this->getQuery($user, false, $offset, $archived, $page, $perPage));
foreach($results->fetchAll() as $notif) { foreach($results->fetchAll() as $notif) {
$originModel = $this->getModel($notif->originModelType, $notif->originModelId); $originModel = $this->getModel($notif->originModelType, $notif->originModelId);