Files
TijdVoorDeTest/src/Repository/CandidateRepository.php
T
Marijn 1c1ce5e071 Update composer.lock with dependency upgrades and improvements (#79)
* Update composer.lock with dependency upgrades and improvements

Updated multiple dependencies in `composer.lock` to their latest versions, including upgrades for Doctrine, PHPUnit, Symfony components, and extended PostgreSQL support.

* Fix sass compile
2026-03-22 22:26:56 +00:00

40 lines
1.1 KiB
PHP

<?php
declare(strict_types=1);
namespace Tvdt\Repository;
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
use Doctrine\Persistence\ManagerRegistry;
use Safe\Exceptions\UrlException;
use Tvdt\Entity\Candidate;
use Tvdt\Entity\Season;
use Tvdt\Helpers\Base64;
/** @extends ServiceEntityRepository<Candidate> */
class CandidateRepository extends ServiceEntityRepository
{
public function __construct(ManagerRegistry $registry)
{
parent::__construct($registry, Candidate::class);
}
public function getCandidateByHash(Season $season, string $hash): ?Candidate
{
try {
$name = Base64::base64UrlDecode($hash);
} catch (UrlException) {
return null;
}
return $this->getEntityManager()->createQuery(<<<DQL
select c from Tvdt\Entity\Candidate c
where c.season = :season
and lower(c.name) = lower(:name)
DQL
)->setParameter('season', $season)
->setParameter('name', $name)
->getOneOrNullResult();
}
}