fix(project) : sélection du workflow à la création + filet par défaut #29

Merged
matthieu merged 3 commits from fix/project-creation-workflow into develop 2026-06-26 14:52:45 +00:00
Showing only changes of commit 49267ad2fb - Show all commits
@@ -7,6 +7,7 @@ namespace App\Module\ProjectManagement\Infrastructure\EventListener;
use App\Module\ProjectManagement\Domain\Entity\Project;
use App\Module\ProjectManagement\Domain\Repository\WorkflowRepositoryInterface;
use Doctrine\ORM\Event\PrePersistEventArgs;
use RuntimeException;
/**
* Assigns the default workflow to a project when none was provided.
@@ -26,8 +27,10 @@ final readonly class ProjectDefaultWorkflowListener
$default = $this->workflowRepository->findDefault()
?? ($this->workflowRepository->findBy([], ['position' => 'ASC'], 1)[0] ?? null);
if (null !== $default) {
$project->setWorkflow($default);
if (null === $default) {
throw new RuntimeException('Cannot create a project: no workflow exists. Seed at least one workflow first.');
}
$project->setWorkflow($default);
}
}