mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-08-20 14:43:49 +00:00
add validation to accompanying periods
This commit is contained in:
@@ -54,10 +54,14 @@ class AccompanyingCourseApiController extends ApiController
|
||||
$accompanyingPeriod = $this->getEntity('participation', $id, $request);
|
||||
|
||||
$this->checkACL('confirm', $request, $_format, $accompanyingPeriod);
|
||||
$workflow = $this->registry->get($accompanyingPeriod);
|
||||
$workflow = $this->registry->get($accompanyingPeriod);
|
||||
|
||||
if (FALSE === $workflow->can($accompanyingPeriod, 'confirm')) {
|
||||
throw new BadRequestException('It is not possible to confirm this period');
|
||||
// throw new BadRequestException('It is not possible to confirm this period');
|
||||
$errors = $this->validator->validate($accompanyingPeriod, null, [$accompanyingPeriod::STEP_CONFIRMED]);
|
||||
if( count($errors) > 0 ){
|
||||
return $this->json($errors, 422);
|
||||
}
|
||||
}
|
||||
|
||||
$workflow->apply($accompanyingPeriod, 'confirm');
|
||||
@@ -109,6 +113,13 @@ $workflow = $this->registry->get($accompanyingPeriod);
|
||||
|
||||
public function resourceApi($id, Request $request, string $_format): Response
|
||||
{
|
||||
$accompanyingPeriod = $this->getEntity('resource', $id, $request);
|
||||
$errors = $this->validator->validate($accompanyingPeriod);
|
||||
|
||||
if ($errors->count() > 0) {
|
||||
return $this->json($errors, 422);
|
||||
}
|
||||
|
||||
return $this->addRemoveSomething('resource', $id, $request, $_format, 'resource', Resource::class);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user