mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-07 18:44:08 +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",
|
||||
* name="chill_relation_relationship_by_person")
|
||||
* name="chill_relationship_by_person")
|
||||
*
|
||||
* @ParamConverter("person", options={"id" = "person_id"})
|
||||
*/
|
||||
|
@ -35,6 +35,12 @@ class Relation
|
||||
*/
|
||||
private array $reverseTitle = [];
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="boolean", nullable=true)
|
||||
* @Serializer\Groups({"read"})
|
||||
*/
|
||||
private bool $isActive = true;
|
||||
|
||||
public function getId(): ?int
|
||||
{
|
||||
return $this->id;
|
||||
@ -63,4 +69,16 @@ class Relation
|
||||
|
||||
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;
|
||||
|
||||
use App\Entity\Relation;
|
||||
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
|
||||
use Doctrine\Persistence\ManagerRegistry;
|
||||
use Chill\PersonBundle\Entity\Relationships\Relation;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
use Doctrine\ORM\EntityRepository;
|
||||
use Doctrine\Persistence\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
|
||||
class RelationRepository implements ObjectRepository
|
||||
{
|
||||
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);
|
||||
}
|
||||
|
||||
// /**
|
||||
// * @return Relation[] Returns an array of Relation objects
|
||||
// */
|
||||
/*
|
||||
public function findByExampleField($value)
|
||||
public function findAll(): array
|
||||
{
|
||||
return $this->createQueryBuilder('r')
|
||||
->andWhere('r.exampleField = :val')
|
||||
->setParameter('val', $value)
|
||||
->orderBy('r.id', 'ASC')
|
||||
->setMaxResults(10)
|
||||
->getQuery()
|
||||
->getResult()
|
||||
;
|
||||
return $this->repository->findAll();
|
||||
}
|
||||
*/
|
||||
|
||||
/*
|
||||
public function findOneBySomeField($value): ?Relation
|
||||
public function findBy(array $criteria, ?array $orderBy = null, $limit = null, $offset = null): array
|
||||
{
|
||||
return $this->createQueryBuilder('r')
|
||||
->andWhere('r.exampleField = :val')
|
||||
->setParameter('val', $value)
|
||||
->getQuery()
|
||||
->getOneOrNullResult()
|
||||
;
|
||||
return $this->repository->findBy($criteria, $orderBy, $limit, $offset);
|
||||
}
|
||||
|
||||
public function findOneBy(array $criteria): ?Relation
|
||||
{
|
||||
return $this->findOneBy($criteria);
|
||||
}
|
||||
|
||||
public function getClassName(): string
|
||||
{
|
||||
return MaritalStatus::class;
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
@ -3,30 +3,50 @@
|
||||
namespace Chill\PersonBundle\Repository\Relationships;
|
||||
|
||||
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\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
|
||||
class RelationshipRepository implements ObjectRepository
|
||||
{
|
||||
public function __construct(ManagerRegistry $registry)
|
||||
|
||||
private EntityRepository $repository;
|
||||
|
||||
public function __construct(EntityManagerInterface $em)
|
||||
{
|
||||
parent::__construct($registry, Relationship::class);
|
||||
$this->repository = $em->getRepository(Relationship::class);
|
||||
}
|
||||
|
||||
// /**
|
||||
// * @return Relationship[] Returns an array of Relationship objects linked to certain person.
|
||||
// */
|
||||
public function find($id): ?Relationship
|
||||
{
|
||||
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 $this->createQueryBuilder('r')
|
||||
return $this->repository->createQueryBuilder('r')
|
||||
->select('r, t') // entity Relationship
|
||||
->join('r.relation', 't')
|
||||
->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