mirror of
https://github.com/MarijnDoeve/TijdVoorDeTest.git
synced 2026-07-05 15:10:16 +02:00
1c1ce5e071
* 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
40 lines
1.1 KiB
PHP
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();
|
|
}
|
|
}
|