filter out active centers in api

This commit is contained in:
Julie Lenaerts 2023-09-11 16:37:27 +02:00
parent 9600543fec
commit 4d111cd6cf

View File

@ -13,6 +13,7 @@ namespace Chill\PersonBundle\Controller;
use Chill\MainBundle\CRUD\Controller\ApiController;
use Chill\MainBundle\Entity\Address;
use Chill\MainBundle\Entity\Center;
use Chill\PersonBundle\Config\ConfigPersonAltNamesHelper;
use Chill\PersonBundle\Entity\AccompanyingPeriodParticipation;
use Chill\PersonBundle\Entity\Person;
@ -52,11 +53,13 @@ class PersonApiController extends ApiController
{
$centers = $this->authorizedCenterOnPersonCreation->getCenters();
$centersActive = array_filter($centers, fn(Center $c) => $c->getIsActive());
return $this->json(
['showCenters' => $this->showCenters, 'centers' => $centers],
['showCenters' => $this->showCenters, 'centers' => $centersActive],
Response::HTTP_OK,
[],
['gropus' => ['read']]
['groups' => ['read']]
);
}