Players used to get bounced back to the dashboard when a session wasn't full yet. Now they land on a lobby page showing who has joined, and can chat with each other while waiting - messages are broadcast live over the existing Mercure hub, and the session auto-starts (and the lobby notifies everyone) once it fills up. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
34 lines
881 B
PHP
34 lines
881 B
PHP
<?php
|
|
|
|
namespace App\Game\Repository;
|
|
|
|
use App\Game\Entity\LobbyMessage;
|
|
use App\Game\Entity\Session;
|
|
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
|
|
use Doctrine\Persistence\ManagerRegistry;
|
|
|
|
/**
|
|
* @extends ServiceEntityRepository<LobbyMessage>
|
|
*/
|
|
class LobbyMessageRepository extends ServiceEntityRepository
|
|
{
|
|
public function __construct(ManagerRegistry $registry)
|
|
{
|
|
parent::__construct($registry, LobbyMessage::class);
|
|
}
|
|
|
|
/**
|
|
* @return LobbyMessage[]
|
|
*/
|
|
public function findForSession(Session $session, int $limit = 100): array
|
|
{
|
|
return $this->createQueryBuilder('m')
|
|
->andWhere('m.session = :session')
|
|
->setParameter('session', $session)
|
|
->orderBy('m.createdAt', 'ASC')
|
|
->setMaxResults($limit)
|
|
->getQuery()
|
|
->getResult();
|
|
}
|
|
}
|