mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-07 18:44:08 +00:00
Endpoint created + swagger documentation + controller action
This commit is contained in:
parent
05e9f118d7
commit
a399804094
@ -332,6 +332,23 @@ final class AccompanyingCourseApiController extends ApiController
|
||||
return $this->json($accompanyingCourse->isConfidential(), Response::HTTP_OK, [], ['groups' => ['read']]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @Route("/api/1.0/person/accompanying-course/{id}/intensity.json", name="chill_api_person_accompanying_period_intensity")
|
||||
* @ParamConverter("accompanyingCourse", options={"id": "id"})
|
||||
*/
|
||||
public function toggleIntensityApi(AccompanyingPeriod $accompanyingCourse, Request $request)
|
||||
{
|
||||
if ($request->getMethod() === 'POST') {
|
||||
$this->denyAccessUnlessGranted(AccompanyingPeriodVoter::TOGGLE_INTENSITY, $accompanyingCourse);
|
||||
|
||||
$status = $accompanyingCourse->getIntensity() == 'regular' ? 'occasional' : 'regular';
|
||||
$accompanyingCourse->setIntensity($status);
|
||||
$this->getDoctrine()->getManager()->flush();
|
||||
}
|
||||
|
||||
return $this->json($accompanyingCourse->getIntensity(), Response::HTTP_OK, [], ['groups' => ['read']]);
|
||||
}
|
||||
|
||||
public function workApi($id, Request $request, string $_format): Response
|
||||
{
|
||||
return $this->addRemoveSomething(
|
||||
|
@ -405,6 +405,16 @@ class ChillPersonExtension extends Extension implements PrependExtensionInterfac
|
||||
Request::METHOD_POST => \Chill\PersonBundle\Security\Authorization\AccompanyingPeriodVoter::TOGGLE_CONFIDENTIAL,
|
||||
],
|
||||
],
|
||||
'intensity' => [
|
||||
'methods' => [
|
||||
Request::METHOD_POST => true,
|
||||
Request::METHOD_GET => true,
|
||||
],
|
||||
'controller_action' => 'toggleIntensityApi',
|
||||
'roles' => [
|
||||
Request::METHOD_POST => \Chill\PersonBundle\Security\Authorization\AccompanyingPeriodVoter::TOGGLE_INTENSITY,
|
||||
],
|
||||
],
|
||||
'findAccompanyingPeriodsByPerson' => [
|
||||
'path' => '/by-person/{person_id}.{_format}',
|
||||
'controller_action' => 'getAccompanyingPeriodsByPerson',
|
||||
|
@ -1177,6 +1177,44 @@ paths:
|
||||
422:
|
||||
description: "object with validation errors"
|
||||
|
||||
/1.0/person/accompanying-course/{id}/intensity.json:
|
||||
post:
|
||||
tags:
|
||||
- person
|
||||
summary: "Toggle intensity status of accompanying course"
|
||||
parameters:
|
||||
- name: id
|
||||
in: path
|
||||
required: true
|
||||
description: The accompanying period's id
|
||||
schema:
|
||||
type: integer
|
||||
format: integer
|
||||
minimum: 1
|
||||
requestBody:
|
||||
description: "Intensity toggle"
|
||||
required: true
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
type: object
|
||||
properties:
|
||||
type:
|
||||
type: string
|
||||
enum:
|
||||
- "accompanying_period"
|
||||
intensity:
|
||||
type: string
|
||||
responses:
|
||||
401:
|
||||
description: "Unauthorized"
|
||||
404:
|
||||
description: "Not found"
|
||||
200:
|
||||
description: "OK"
|
||||
422:
|
||||
description: "object with validation errors"
|
||||
|
||||
/1.0/person/accompanying-course/by-person/{person_id}.json:
|
||||
get:
|
||||
tags:
|
||||
|
Loading…
x
Reference in New Issue
Block a user