feat: add Game and GameRow repositories

This commit is contained in:
thibaud-leclere
2026-03-30 19:43:39 +02:00
parent ff9a48448c
commit 665233425a
2 changed files with 53 additions and 0 deletions

View File

@@ -0,0 +1,33 @@
<?php
declare(strict_types=1);
namespace App\Repository;
use App\Entity\Game;
use App\Entity\User;
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
use Doctrine\Persistence\ManagerRegistry;
/**
* @extends ServiceEntityRepository<Game>
*/
class GameRepository extends ServiceEntityRepository
{
public function __construct(ManagerRegistry $registry)
{
parent::__construct($registry, Game::class);
}
public function findActiveForUser(User $user): ?Game
{
return $this->createQueryBuilder('g')
->andWhere('g.user = :user')
->andWhere('g.status = :status')
->setParameter('user', $user)
->setParameter('status', Game::STATUS_IN_PROGRESS)
->setMaxResults(1)
->getQuery()
->getOneOrNullResult();
}
}

View File

@@ -0,0 +1,20 @@
<?php
declare(strict_types=1);
namespace App\Repository;
use App\Entity\GameRow;
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
use Doctrine\Persistence\ManagerRegistry;
/**
* @extends ServiceEntityRepository<GameRow>
*/
class GameRowRepository extends ServiceEntityRepository
{
public function __construct(ManagerRegistry $registry)
{
parent::__construct($registry, GameRow::class);
}
}