endpoint created for acc periods by-person

This commit is contained in:
Julie Lenaerts 2021-10-20 13:11:58 +02:00
parent 1b0c19a68f
commit 902c45f0cd
4 changed files with 61 additions and 5 deletions

View File

@ -18,7 +18,11 @@ use Chill\PersonBundle\Entity\AccompanyingPeriod\Resource;
use Chill\PersonBundle\Entity\AccompanyingPeriod\Comment;
use Chill\PersonBundle\Entity\SocialWork\SocialIssue;
use Chill\MainBundle\Entity\Scope;
use Chill\PersonBundle\Repository\AccompanyingPeriodACLAwareRepository;
use Chill\PersonBundle\Security\Authorization\AccompanyingPeriodVoter;
use Symfony\Component\Workflow\Registry;
use Symfony\Component\Routing\Annotation\Route;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\ParamConverter;
class AccompanyingCourseApiController extends ApiController
{
@ -28,14 +32,18 @@ class AccompanyingCourseApiController extends ApiController
private Registry $registry;
private AccompanyingPeriodACLAwareRepository $accompanyingPeriodACLAwareRepository;
public function __construct(
EventDispatcherInterface $eventDispatcher,
ValidatorInterface $validator,
Registry $registry
Registry $registry,
AccompanyingPeriodACLAwareRepository $accompanyingPeriodACLAwareRepository
) {
$this->eventDispatcher = $eventDispatcher;
$this->validator = $validator;
$this->registry = $registry;
$this->accompanyingPeriodACLAwareRepository = $accompanyingPeriodACLAwareRepository;
}
public function confirmApi($id, Request $request, $_format): Response
@ -187,4 +195,19 @@ $workflow = $this->registry->get($accompanyingPeriod);
return null;
}
/**
* @Route("/api/1.0/person/accompanying-course/by-person/{person_id}.{_format}",
* name="chill_person_accompanyingperiod_by_person",
* requirements={
* "_format"="json"
* })
*
* @ParamConverter("person", options={"id" = "person_id"})
*/
public function getAccompanyingPeriodsByPerson(Person $person){
$accompanyingPeriods = $person->getAccompanyingPeriods();
return $this->json(\array_values($accompanyingPeriods), Response::HTTP_OK, [], ['groups' => [ 'read']]);
}
}

View File

@ -585,6 +585,14 @@ class ChillPersonExtension extends Extension implements PrependExtensionInterfac
Request::METHOD_POST => \Chill\PersonBundle\Security\Authorization\AccompanyingPeriodVoter::SEE,
]
],
'findAccompanyingPeriodsByPerson' => [
'path' => '/by-person/{person_id}.{_format}',
'controller_action' => 'findAccompanyingPeriodsByPerson',
'methods' => [
Request::METHOD_GET => true,
Request::METHOD_HEAD => true,
]
]
]
],
[

View File

@ -1058,6 +1058,29 @@ paths:
description: "OK"
400:
description: "transition cannot be applyed"
/1.0/person/accompanying-course/by-person/{person_id}.json:
get:
tags:
- accompanying period
summary: get a list of accompanying periods for a person
description: Returns a list of the current accompanying periods for a person
parameters:
- name: person_id
in: path
required: true
description: The person id
schema:
type: integer
format: integer
minimum: 1
responses:
401:
description: "Unauthorized"
404:
description: "Not found"
200:
description: "OK"
/1.0/person/accompanying-period/origin.json:
get:

View File

@ -41,10 +41,12 @@ services:
tags: ['controller.service_arguments']
Chill\PersonBundle\Controller\AccompanyingCourseApiController:
arguments:
$eventDispatcher: '@Symfony\Contracts\EventDispatcher\EventDispatcherInterface'
$validator: '@Symfony\Component\Validator\Validator\ValidatorInterface'
$registry: '@Symfony\Component\Workflow\Registry'
autowire: true
autoconfigure: true
# arguments:
# $eventDispatcher: '@Symfony\Contracts\EventDispatcher\EventDispatcherInterface'
# $validator: '@Symfony\Component\Validator\Validator\ValidatorInterface'
# $registry: '@Symfony\Component\Workflow\Registry'
tags: ['controller.service_arguments']
Chill\PersonBundle\Controller\PersonApiController: