Add Symfony payload mapping, fixtures, and QA tooling
This commit is contained in:
@@ -0,0 +1,39 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Repository;
|
||||
|
||||
use App\Entity\Signal;
|
||||
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
|
||||
use Doctrine\Persistence\ManagerRegistry;
|
||||
|
||||
/**
|
||||
* @extends ServiceEntityRepository<Signal>
|
||||
*/
|
||||
class SignalRepository extends ServiceEntityRepository
|
||||
{
|
||||
public function __construct(ManagerRegistry $registry)
|
||||
{
|
||||
parent::__construct($registry, Signal::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return list<Signal>
|
||||
*/
|
||||
public function findRecent(int $limit): array
|
||||
{
|
||||
return $this->createQueryBuilder('signal')
|
||||
->orderBy('signal.createdAt', 'DESC')
|
||||
->setMaxResults($limit)
|
||||
->getQuery()
|
||||
->getResult();
|
||||
}
|
||||
|
||||
public function save(Signal $signal): void
|
||||
{
|
||||
$entityManager = $this->getEntityManager();
|
||||
$entityManager->persist($signal);
|
||||
$entityManager->flush();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user