mirror of
https://github.com/MarijnDoeve/TijdVoorDeTest.git
synced 2026-03-06 20:54:20 +01:00
This commit removes nullable Uuid properties for consistency, transitions the Correction entity to QuizCandidate with associated migrations, refactors queries and repositories, adjusts related routes and controllers to use the new entity, updates front-end assets for elimination workflows, and standardizes route requirements and naming conventions.
37 lines
961 B
PHP
37 lines
961 B
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace App\Repository;
|
|
|
|
use App\Entity\Candidate;
|
|
use App\Entity\Quiz;
|
|
use App\Entity\QuizCandidate;
|
|
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
|
|
use Doctrine\Persistence\ManagerRegistry;
|
|
|
|
/**
|
|
* @extends ServiceEntityRepository<QuizCandidate>
|
|
*/
|
|
class QuizCandidateRepository extends ServiceEntityRepository
|
|
{
|
|
public function __construct(ManagerRegistry $registry)
|
|
{
|
|
parent::__construct($registry, QuizCandidate::class);
|
|
}
|
|
|
|
/** @return bool true if a new entry was created */
|
|
public function createIfNotExist(Quiz $quiz, Candidate $candidate): bool
|
|
{
|
|
if (0 !== $this->count(['candidate' => $candidate, 'quiz' => $quiz])) {
|
|
return false;
|
|
}
|
|
|
|
$quizCandidate = new QuizCandidate($quiz, $candidate);
|
|
$this->getEntityManager()->persist($quizCandidate);
|
|
$this->getEntityManager()->flush();
|
|
|
|
return true;
|
|
}
|
|
}
|