Configure database sessions

This commit is contained in:
2024-07-03 11:03:13 +02:00
parent 1a5ba16ef9
commit 096d35d5cf
23 changed files with 1008 additions and 24 deletions

View File

@@ -0,0 +1,60 @@
<?php
namespace App\Repository;
use App\Entity\Comment;
use App\Entity\Conference;
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
use Doctrine\Persistence\ManagerRegistry;
use Doctrine\ORM\Tools\Pagination\Paginator;
/**
* @extends ServiceEntityRepository<Comment>
*/
class CommentRepository extends ServiceEntityRepository
{
public const COMMENTS_PER_PAGE = 2;
public function __construct(ManagerRegistry $registry)
{
parent::__construct($registry, Comment::class);
}
public function getCommentPaginator(Conference $conference, int $offset): Paginator
{
$query = $this->createQueryBuilder('c')
->andWhere('c.conference = :conference')
->setParameter('conference', $conference)
->orderBy('c.createdAt', 'DESC')
->setMaxResults(self::COMMENTS_PER_PAGE)
->setFirstResult($offset)
->getQuery()
;
return new Paginator($query);
}
// /**
// * @return Comment[] Returns an array of Comment objects
// */
// public function findByExampleField($value): array
// {
// return $this->createQueryBuilder('c')
// ->andWhere('c.exampleField = :val')
// ->setParameter('val', $value)
// ->orderBy('c.id', 'ASC')
// ->setMaxResults(10)
// ->getQuery()
// ->getResult()
// ;
// }
// public function findOneBySomeField($value): ?Comment
// {
// return $this->createQueryBuilder('c')
// ->andWhere('c.exampleField = :val')
// ->setParameter('val', $value)
// ->getQuery()
// ->getOneOrNullResult()
// ;
// }
}