fix(notifications) : pagination réelle côté provider pour ne plus tronquer à 30 (LST-52)
NotificationProvider retournait findBy(..., 30) : limite codée en dur, paramètre page ignoré et tableau brut (pas un Paginator). hydra:totalItems valait donc 30 → fetchAllHydra s'arrêtait à la 1re page et les notifications restaient tronquées à 30 malgré le correctif front. - NotificationProvider : vraie pagination Doctrine (Pagination + DoctrinePaginator + TraversablePaginator), totalItems réel et hydra:view.next exposés - NotificationRepository : createUserNotificationsQueryBuilder (filtre user + tri) - fetchAllHydra : ne retronque plus silencieusement quand hydra:totalItems est absent, pagine jusqu'à une page non pleine
This commit is contained in:
@@ -7,7 +7,9 @@ namespace App\Repository;
|
||||
use App\Entity\Notification;
|
||||
use App\Entity\User;
|
||||
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
|
||||
use Doctrine\ORM\QueryBuilder;
|
||||
use Doctrine\Persistence\ManagerRegistry;
|
||||
use Symfony\Component\Security\Core\User\UserInterface;
|
||||
|
||||
/**
|
||||
* @extends ServiceEntityRepository<Notification>
|
||||
@@ -19,6 +21,15 @@ class NotificationRepository extends ServiceEntityRepository
|
||||
parent::__construct($registry, Notification::class);
|
||||
}
|
||||
|
||||
public function createUserNotificationsQueryBuilder(UserInterface $user): QueryBuilder
|
||||
{
|
||||
return $this->createQueryBuilder('n')
|
||||
->where('n.user = :user')
|
||||
->setParameter('user', $user)
|
||||
->orderBy('n.createdAt', 'DESC')
|
||||
;
|
||||
}
|
||||
|
||||
public function countUnreadByUser(User $user): int
|
||||
{
|
||||
return (int) $this->createQueryBuilder('n')
|
||||
|
||||
Reference in New Issue
Block a user