endpoint created for acc periods by-person

This commit is contained in:
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']]);
}
}