mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-18 16:24:24 +00:00
47 lines
1.6 KiB
PHP
47 lines
1.6 KiB
PHP
<?php
|
|
|
|
namespace Chill\PersonBundle\Controller;
|
|
|
|
use Chill\MainBundle\Pagination\PaginatorFactory;
|
|
use Chill\MainBundle\Serializer\Model\Collection;
|
|
use Chill\PersonBundle\Entity\SocialWork\SocialAction;
|
|
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
|
use Symfony\Component\HttpFoundation\Response;
|
|
use Symfony\Component\Routing\Annotation\Route;
|
|
use Sensio\Bundle\FrameworkExtraBundle\Configuration\ParamConverter;
|
|
|
|
class SocialWorkEvaluationApiController extends AbstractController
|
|
{
|
|
private PaginatorFactory $paginatorFactory;
|
|
|
|
/**
|
|
* @param PaginatorFactory $paginatorFactory
|
|
*/
|
|
public function __construct(PaginatorFactory $paginatorFactory)
|
|
{
|
|
$this->paginatorFactory = $paginatorFactory;
|
|
}
|
|
|
|
/**
|
|
* @Route("/api/1.0/person/social-work/evaluation/by-social-action/{action_id}.json",
|
|
* name="chill_person_evaluation_index_by_social_action",
|
|
* requirements={
|
|
* "_format": "json"
|
|
* }
|
|
* )
|
|
* @ParamConverter("action", options={"id": "action_id"})
|
|
* @param SocialAction $action
|
|
* @return Response
|
|
*/
|
|
public function listEvaluationBySocialAction(SocialAction $action): Response
|
|
{
|
|
$pagination = $this->paginatorFactory->create($action->getEvaluations()->count());
|
|
|
|
$evaluations = $action->getEvaluations()->slice($pagination->getCurrentPageFirstItemNumber(),
|
|
$pagination->getItemsPerPage());
|
|
$collection = new Collection($evaluations, $pagination);
|
|
|
|
return $this->json($collection, Response::HTTP_OK, [], [ 'groups' => [ 'read' ]]);
|
|
}
|
|
}
|