mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-12 13:24:25 +00:00
processing of review. still ACL left to do
This commit is contained in:
parent
e1d28289f6
commit
50fbc7fd15
@ -25,7 +25,7 @@ class RelationshipApiController extends ApiController
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @Route("/api/1.0/relation/relationship/by-person/{person_id}.json",
|
* @Route("/api/1.0/relation/relationship/by-person/{person_id}.json",
|
||||||
* name="chill_relation_relationship_by_person")
|
* name="chill_relationship_by_person")
|
||||||
*
|
*
|
||||||
* @ParamConverter("person", options={"id" = "person_id"})
|
* @ParamConverter("person", options={"id" = "person_id"})
|
||||||
*/
|
*/
|
||||||
|
@ -35,6 +35,12 @@ class Relation
|
|||||||
*/
|
*/
|
||||||
private array $reverseTitle = [];
|
private array $reverseTitle = [];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ORM\Column(type="boolean", nullable=true)
|
||||||
|
* @Serializer\Groups({"read"})
|
||||||
|
*/
|
||||||
|
private bool $isActive = true;
|
||||||
|
|
||||||
public function getId(): ?int
|
public function getId(): ?int
|
||||||
{
|
{
|
||||||
return $this->id;
|
return $this->id;
|
||||||
@ -63,4 +69,16 @@ class Relation
|
|||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getIsActive(): bool
|
||||||
|
{
|
||||||
|
return $this->isActive;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setIsActive(?bool $isActive): self
|
||||||
|
{
|
||||||
|
$this->isActive = $isActive;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
}
|
}
|
@ -2,49 +2,41 @@
|
|||||||
|
|
||||||
namespace Chill\PersonBundle\Repository\Relationships;
|
namespace Chill\PersonBundle\Repository\Relationships;
|
||||||
|
|
||||||
use App\Entity\Relation;
|
use Chill\PersonBundle\Entity\Relationships\Relation;
|
||||||
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
|
use Doctrine\ORM\EntityManagerInterface;
|
||||||
use Doctrine\Persistence\ManagerRegistry;
|
use Doctrine\ORM\EntityRepository;
|
||||||
|
use Doctrine\Persistence\ObjectRepository;
|
||||||
|
|
||||||
/**
|
class RelationRepository implements ObjectRepository
|
||||||
* @method Relation|null find($id, $lockMode = null, $lockVersion = null)
|
|
||||||
* @method Relation|null findOneBy(array $criteria, array $orderBy = null)
|
|
||||||
* @method Relation[] findAll()
|
|
||||||
* @method Relation[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
|
|
||||||
*/
|
|
||||||
class RelationRepository extends ServiceEntityRepository
|
|
||||||
{
|
{
|
||||||
public function __construct(ManagerRegistry $registry)
|
private EntityRepository $repository;
|
||||||
|
|
||||||
|
public function __construct(EntityManagerInterface $entityManager)
|
||||||
{
|
{
|
||||||
parent::__construct($registry, Relation::class);
|
$this->repository = $entityManager->getRepository(Relation::class);
|
||||||
|
}
|
||||||
|
public function find($id): ?Relation
|
||||||
|
{
|
||||||
|
return $this->repository->find($id);
|
||||||
}
|
}
|
||||||
|
|
||||||
// /**
|
public function findAll(): array
|
||||||
// * @return Relation[] Returns an array of Relation objects
|
|
||||||
// */
|
|
||||||
/*
|
|
||||||
public function findByExampleField($value)
|
|
||||||
{
|
{
|
||||||
return $this->createQueryBuilder('r')
|
return $this->repository->findAll();
|
||||||
->andWhere('r.exampleField = :val')
|
|
||||||
->setParameter('val', $value)
|
|
||||||
->orderBy('r.id', 'ASC')
|
|
||||||
->setMaxResults(10)
|
|
||||||
->getQuery()
|
|
||||||
->getResult()
|
|
||||||
;
|
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
|
|
||||||
/*
|
public function findBy(array $criteria, ?array $orderBy = null, $limit = null, $offset = null): array
|
||||||
public function findOneBySomeField($value): ?Relation
|
|
||||||
{
|
{
|
||||||
return $this->createQueryBuilder('r')
|
return $this->repository->findBy($criteria, $orderBy, $limit, $offset);
|
||||||
->andWhere('r.exampleField = :val')
|
}
|
||||||
->setParameter('val', $value)
|
|
||||||
->getQuery()
|
public function findOneBy(array $criteria): ?Relation
|
||||||
->getOneOrNullResult()
|
{
|
||||||
;
|
return $this->findOneBy($criteria);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getClassName(): string
|
||||||
|
{
|
||||||
|
return MaritalStatus::class;
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
|
@ -3,30 +3,50 @@
|
|||||||
namespace Chill\PersonBundle\Repository\Relationships;
|
namespace Chill\PersonBundle\Repository\Relationships;
|
||||||
|
|
||||||
use Chill\PersonBundle\Entity\Relationships\Relationship;
|
use Chill\PersonBundle\Entity\Relationships\Relationship;
|
||||||
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
|
use Doctrine\ORM\EntityManagerInterface;
|
||||||
|
use Doctrine\ORM\EntityRepository;
|
||||||
use Doctrine\Persistence\ManagerRegistry;
|
use Doctrine\Persistence\ManagerRegistry;
|
||||||
|
use Doctrine\Persistence\ObjectRepository;
|
||||||
|
|
||||||
/**
|
class RelationshipRepository implements ObjectRepository
|
||||||
* @method Relationship|null find($id, $lockMode = null, $lockVersion = null)
|
|
||||||
* @method Relationship|null findOneBy(array $criteria, array $orderBy = null)
|
|
||||||
* @method Relationship[] findAll()
|
|
||||||
* @method Relationship[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
|
|
||||||
*/
|
|
||||||
class RelationshipRepository extends ServiceEntityRepository
|
|
||||||
{
|
{
|
||||||
public function __construct(ManagerRegistry $registry)
|
|
||||||
|
private EntityRepository $repository;
|
||||||
|
|
||||||
|
public function __construct(EntityManagerInterface $em)
|
||||||
{
|
{
|
||||||
parent::__construct($registry, Relationship::class);
|
$this->repository = $em->getRepository(Relationship::class);
|
||||||
}
|
}
|
||||||
|
|
||||||
// /**
|
public function find($id): ?Relationship
|
||||||
// * @return Relationship[] Returns an array of Relationship objects linked to certain person.
|
{
|
||||||
// */
|
return $this->repository->find($id);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function findAll(): array
|
||||||
|
{
|
||||||
|
return $this->repository->findAll();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function findBy(array $criteria, ?array $orderBy = null, $limit = null, $offset = null): array
|
||||||
|
{
|
||||||
|
return $this->repository->findBy($criteria, $orderBy, $limit, $offset);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function findOneBy(array $criteria): ?Relationship
|
||||||
|
{
|
||||||
|
return $this->findOneBy($criteria);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getClassName(): string
|
||||||
|
{
|
||||||
|
return MaritalStatus::class;
|
||||||
|
}
|
||||||
|
|
||||||
public function findByPerson($personId)
|
public function findByPerson($personId): array
|
||||||
{
|
{
|
||||||
// return all relationships of which person is part? or only where person is the fromPerson?
|
// return all relationships of which person is part? or only where person is the fromPerson?
|
||||||
return $this->createQueryBuilder('r')
|
return $this->repository->createQueryBuilder('r')
|
||||||
->select('r, t') // entity Relationship
|
->select('r, t') // entity Relationship
|
||||||
->join('r.relation', 't')
|
->join('r.relation', 't')
|
||||||
->where('r.fromPerson = :val')
|
->where('r.fromPerson = :val')
|
||||||
|
@ -1,38 +0,0 @@
|
|||||||
<?php
|
|
||||||
declare(strict_types=1);
|
|
||||||
|
|
||||||
namespace Chill\PersonBundle\Serializer\Normalizer;
|
|
||||||
|
|
||||||
use Chill\PersonBundle\Entity\Relationships\Relationship;
|
|
||||||
use Symfony\Component\Serializer\Normalizer\DenormalizerAwareTrait;
|
|
||||||
use Symfony\Component\Serializer\Normalizer\NormalizerAwareInterface;
|
|
||||||
use Symfony\Component\Serializer\Normalizer\NormalizerAwareTrait;
|
|
||||||
use Symfony\Component\Serializer\Normalizer\NormalizerInterface;
|
|
||||||
use Symfony\Component\Serializer\Normalizer\ObjectToPopulateTrait;
|
|
||||||
|
|
||||||
class RelationshipNormalizer implements NormalizerInterface, NormalizerAwareInterface
|
|
||||||
{
|
|
||||||
use NormalizerAwareTrait;
|
|
||||||
|
|
||||||
use ObjectToPopulateTrait;
|
|
||||||
|
|
||||||
use DenormalizerAwareTrait;
|
|
||||||
|
|
||||||
public function normalize($relationship, ?string $format = null, array $context = [])
|
|
||||||
{
|
|
||||||
return [
|
|
||||||
'type' => 'relationship',
|
|
||||||
'id' => $this->normalizer->normalize($relationship->getId()),
|
|
||||||
'fromPerson' => $this->normalizer->normalize($relationship->getFromPerson()),
|
|
||||||
'toPerson' => $this->normalizer->normalize($relationship->getToPerson()),
|
|
||||||
'relation' => $this->normalizer->normalize($relationship->getRelation()),
|
|
||||||
'reverse' => $relationship->getReverse()
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
public function supportsNormalization($data, ?string $format = null)
|
|
||||||
{
|
|
||||||
return $data instanceof Relationship;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -0,0 +1,29 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace Chill\Migrations\Person;
|
||||||
|
|
||||||
|
use Doctrine\DBAL\Schema\Schema;
|
||||||
|
use Doctrine\Migrations\AbstractMigration;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* isActive property added to Relation entity.
|
||||||
|
*/
|
||||||
|
final class Version20211029075117 extends AbstractMigration
|
||||||
|
{
|
||||||
|
public function getDescription(): string
|
||||||
|
{
|
||||||
|
return 'isActive property added to Relation entity.';
|
||||||
|
}
|
||||||
|
|
||||||
|
public function up(Schema $schema): void
|
||||||
|
{
|
||||||
|
$this->addSql('ALTER TABLE chill_person_relations ADD isActive BOOLEAN NOT NULL');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function down(Schema $schema): void
|
||||||
|
{
|
||||||
|
$this->addSql('ALTER TABLE chill_person_relations DROP isActive');
|
||||||
|
}
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user