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,50 @@
<?php
namespace Chill\PersonBundle\Repository\Relationships;
use App\Entity\Relation;
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
use Doctrine\Persistence\ManagerRegistry;
/**
* @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)
{
parent::__construct($registry, Relation::class);
}
// /**
// * @return Relation[] Returns an array of Relation objects
// */
/*
public function findByExampleField($value)
{
return $this->createQueryBuilder('r')
->andWhere('r.exampleField = :val')
->setParameter('val', $value)
->orderBy('r.id', 'ASC')
->setMaxResults(10)
->getQuery()
->getResult()
;
}
*/
/*
public function findOneBySomeField($value): ?Relation
{
return $this->createQueryBuilder('r')
->andWhere('r.exampleField = :val')
->setParameter('val', $value)
->getQuery()
->getOneOrNullResult()
;
}
*/
}

View File

@@ -0,0 +1,38 @@
<?php
namespace Chill\PersonBundle\Repository\Relationships;
use Chill\PersonBundle\Entity\Relationships\Relationship;
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
use Doctrine\Persistence\ManagerRegistry;
/**
* @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)
{
parent::__construct($registry, Relationship::class);
}
// /**
// * @return Relationship[] Returns an array of Relationship objects linked to certain person.
// */
public function findByPerson($personId)
{
// return all relationships of which person is part? or only where person is the fromPerson?
return $this->createQueryBuilder('r')
->andWhere('r.fromPerson = :val')
->orWhere('r.toPerson = :val')
->setParameter('val', $personId)
->getQuery()
->getResult()
;
}
}