fix: refuse deleting a document assigned to a season task

This commit is contained in:
fromme committed 2026-10-15 13:02:13 +02:00
1 parent 4aa2d7a5e6
commit 3116d23199
7 files changed
+271 -14

No files matched your search

@@ -4,6 +4,7 @@ namespace App\Repository;
use App\Config\SeasonTask;
use App\Entity\SeasonTaskDocument;
use App\Entity\Upload;
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
use Doctrine\Persistence\ManagerRegistry;
@@ -43,4 +44,31 @@ class SeasonTaskDocumentRepository extends ServiceEntityRepository
{
return $this->findOneBy(['taskKey' => $task->value]);
}
/**
* Every mapping that points at the document, including rows whose task key no longer
* resolves: those still hold the foreign key that blocks deleting the upload.
*
* @return array<int, SeasonTaskDocument>
*/
public function findByDocument(Upload $document): array
{
return $this->findBy(['document' => $document]);
}
/**
* The mappings grouped by the id of the document they point at, for the document list.
*
* @return array<int, array<int, SeasonTaskDocument>>
*/
public function findGroupedByDocumentId(): array
{
$grouped = [];
foreach ($this->findAll() as $seasonTaskDocument) {
$grouped[$seasonTaskDocument->getDocument()->getId()][] = $seasonTaskDocument;
}
return $grouped;
}
}