mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-08-05 07:19:49 +00:00
Updated API creation to require an explicit controller definition. This change has been reflected in the ChillMainExtension and ChillPersonExtension files. Also, it has introduced a new exception, the InvalidCrudConfiguration, which will be thrown when a new API or CRUD is created without this explicit controller definition.
37 lines
1.1 KiB
PHP
37 lines
1.1 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
/*
|
|
* Chill is a software for social workers
|
|
*
|
|
* For the full copyright and license information, please view
|
|
* the LICENSE file that was distributed with this source code.
|
|
*/
|
|
|
|
namespace Chill\PersonBundle\Controller;
|
|
|
|
use Chill\MainBundle\CRUD\Controller\ApiController;
|
|
use Chill\PersonBundle\Entity\Person;
|
|
use Chill\PersonBundle\Repository\Relationships\RelationshipRepository;
|
|
use Chill\PersonBundle\Security\Authorization\PersonVoter;
|
|
use Sensio\Bundle\FrameworkExtraBundle\Configuration\ParamConverter;
|
|
use Symfony\Component\HttpFoundation\Response;
|
|
|
|
class RelationshipApiController extends ApiController
|
|
{
|
|
public function __construct(private readonly RelationshipRepository $repository) {}
|
|
|
|
/**
|
|
* @ParamConverter("person", options={"id": "person_id"})
|
|
*/
|
|
public function getRelationshipsByPerson(Person $person)
|
|
{
|
|
$this->denyAccessUnlessGranted(PersonVoter::SEE, $person);
|
|
|
|
$relationships = $this->repository->findByPerson($person);
|
|
|
|
return $this->json($relationships, Response::HTTP_OK, [], ['groups' => ['read']]);
|
|
}
|
|
}
|