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,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()
|
||||
;
|
||||
}
|
||||
*/
|
||||
}
|
@@ -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()
|
||||
;
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user