fix: Permettre l'affectation de classe pour les élèves sans affectation existante
Le handler ChangeStudentClass exigeait une affectation existante pour l'année scolaire en cours avant de pouvoir changer la classe. Un élève créé sans ClassAssignment (import direct, année précédente) provoquait une erreur "Élève non trouvé" au lieu d'être simplement affecté. Le handler crée désormais une nouvelle affectation quand aucune n'existe, et l'erreur de changement de classe s'affiche dans la modale au lieu de la page principale.
This commit is contained in:
@@ -8,7 +8,6 @@ use ApiPlatform\Metadata\Operation;
|
||||
use ApiPlatform\State\ProcessorInterface;
|
||||
use App\Administration\Application\Command\ChangeStudentClass\ChangeStudentClassCommand;
|
||||
use App\Administration\Application\Command\ChangeStudentClass\ChangeStudentClassHandler;
|
||||
use App\Administration\Domain\Exception\AffectationEleveNonTrouveeException;
|
||||
use App\Administration\Domain\Exception\ClasseNotFoundException;
|
||||
use App\Administration\Domain\Repository\ClassRepository;
|
||||
use App\Administration\Infrastructure\Api\Resource\StudentResource;
|
||||
@@ -80,8 +79,6 @@ final readonly class ChangeStudentClassProcessor implements ProcessorInterface
|
||||
$data->classLevel = $newClass->level?->value;
|
||||
|
||||
return $data;
|
||||
} catch (AffectationEleveNonTrouveeException) {
|
||||
throw new NotFoundHttpException('Élève non trouvé.');
|
||||
} catch (ClasseNotFoundException $e) {
|
||||
throw new NotFoundHttpException($e->getMessage());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user