mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-08-21 07:03:49 +00:00
relation and relationship entities created + endpoints. Still something wrong with link between Relation and Relationship
This commit is contained in:
@@ -0,0 +1,38 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Chill\PersonBundle\Controller;
|
||||
|
||||
use Chill\MainBundle\CRUD\Controller\ApiController;
|
||||
use Chill\PersonBundle\Entity\Person;
|
||||
use Chill\PersonBundle\Repository\Relationships\RelationshipRepository;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Symfony\Component\Validator\Validator\ValidatorInterface;
|
||||
use Symfony\Component\Routing\Annotation\Route;
|
||||
use Sensio\Bundle\FrameworkExtraBundle\Configuration\ParamConverter;
|
||||
|
||||
class RelationshipApiController extends ApiController
|
||||
{
|
||||
private ValidatorInterface $validator;
|
||||
private RelationshipRepository $repository;
|
||||
|
||||
public function __construct(ValidatorInterface $validator, RelationshipRepository $repository)
|
||||
{
|
||||
$this->validator = $validator;
|
||||
$this->repository = $repository;
|
||||
}
|
||||
|
||||
/**
|
||||
* @Route("/api/1.0/relation/relationship/by-person/{person_id}.json",
|
||||
* name="chill_relation_relationship_by_person")
|
||||
*
|
||||
* @ParamConverter("person", options={"id" = "person_id"})
|
||||
*/
|
||||
public function getRelationshipsByPerson(Person $person)
|
||||
{
|
||||
//TODO: add permissions? (voter?)
|
||||
$relationships = $this->repository->findByPerson($person);
|
||||
|
||||
return $this->json(\array_values($relationships), Response::HTTP_OK, [], ['groups' => [ 'read']]);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user