relation and relationship entities created + endpoints. Still something wrong with link between Relation and Relationship

This commit is contained in:
2021-10-22 19:21:32 +02:00
parent 6ff80be88d
commit 05d16ec9ab
9 changed files with 539 additions and 7 deletions

View File

@@ -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']]);
}
}