Fix notification error

This commit is contained in:
Xbird
2022-07-21 13:08:18 +00:00
parent 211a6a6c42
commit 0be4dc0060
2 changed files with 11 additions and 10 deletions

View File

@@ -1,3 +1,3 @@
{
"version": "0.2.3"
"version": "0.2.4"
}

View File

@@ -2,6 +2,7 @@
namespace App\EventSubscriber;
use App\Entity\Notification;
use App\Entity\User;
use Twig\Environment;
use Doctrine\ORM\EntityManagerInterface;
@@ -42,7 +43,7 @@ class NotificationsSubscriber implements EventSubscriberInterface
* @var NotificationRepository notificationRepo
*/
if (null === ($notificationRepo = $this->entityManager->getRepository("App:Notification"))) {
if (null === ($notificationRepo = $this->entityManager->getRepository(Notification::class))) {
return;
}
@@ -58,19 +59,19 @@ class NotificationsSubscriber implements EventSubscriberInterface
$this->twig->addGlobal(
'user_notifications_list',
$notificationRepo->listForUser($User)
->readed(false)
->limit(5)
->order(['createdAt' => 'DESC'])
->getResult()
->readed(false)
->limit(5)
->order(['createdAt' => 'DESC'])
->getResult()
);
$this->twig->addGlobal(
'user_notifications_count',
$notificationRepo->listForUser($User)
->readed(false)
->limit(5)
->order(['createdAt' => 'DESC'])
->getCount()
->readed(false)
->limit(5)
->order(['createdAt' => 'DESC'])
->getCount()
);
}