fix(project) : erreur explicite si aucun workflow à la création au lieu d'une violation NOT NULL
Pull Request — Quality gate / Backend (PHP CS + PHPUnit) (pull_request) Has been cancelled
Pull Request — Quality gate / Frontend (build) (pull_request) Has been cancelled

This commit is contained in:
Matthieu
2026-06-26 16:49:33 +02:00
parent d3abb584a9
commit 49267ad2fb
@@ -7,6 +7,7 @@ namespace App\Module\ProjectManagement\Infrastructure\EventListener;
use App\Module\ProjectManagement\Domain\Entity\Project; use App\Module\ProjectManagement\Domain\Entity\Project;
use App\Module\ProjectManagement\Domain\Repository\WorkflowRepositoryInterface; use App\Module\ProjectManagement\Domain\Repository\WorkflowRepositoryInterface;
use Doctrine\ORM\Event\PrePersistEventArgs; use Doctrine\ORM\Event\PrePersistEventArgs;
use RuntimeException;
/** /**
* Assigns the default workflow to a project when none was provided. * Assigns the default workflow to a project when none was provided.
@@ -26,8 +27,10 @@ final readonly class ProjectDefaultWorkflowListener
$default = $this->workflowRepository->findDefault() $default = $this->workflowRepository->findDefault()
?? ($this->workflowRepository->findBy([], ['position' => 'ASC'], 1)[0] ?? null); ?? ($this->workflowRepository->findBy([], ['position' => 'ASC'], 1)[0] ?? null);
if (null !== $default) { if (null === $default) {
$project->setWorkflow($default); throw new RuntimeException('Cannot create a project: no workflow exists. Seed at least one workflow first.');
} }
$project->setWorkflow($default);
} }
} }