mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-14 14:24:24 +00:00
42 lines
1.0 KiB
PHP
42 lines
1.0 KiB
PHP
<?php
|
|
|
|
namespace Chill\PersonBundle\Repository;
|
|
|
|
use Chill\PersonBundle\Entity\Person;
|
|
use Chill\PersonBundle\Entity\PersonNotDuplicate;
|
|
use Doctrine\ORM\EntityRepository;
|
|
|
|
/**
|
|
* Class PersonNotDuplicateRepository
|
|
*
|
|
* @package Chill\PersonBundle\Repository
|
|
*/
|
|
class PersonNotDuplicateRepository extends EntityRepository
|
|
{
|
|
/**
|
|
* @param \Chill\PersonBundle\Entity\Person $person
|
|
*
|
|
* @return array
|
|
*/
|
|
public function findNotDuplicatePerson(Person $person)
|
|
{
|
|
$qb = $this->createQueryBuilder('pnd');
|
|
$qb->select('pnd')
|
|
->where('pnd.person1 = :person OR pnd.person2 = :person')
|
|
;
|
|
$qb->setParameter('person', $person);
|
|
$result = $qb->getQuery()->getResult();
|
|
|
|
$persons = [];
|
|
foreach ($result as $row) {
|
|
if ($row->getPerson1() === $person) {
|
|
$persons[] = $row->getPerson2();
|
|
} elseif ($row->getPerson2() === $person) {
|
|
$persons[] = $row->getPerson1();
|
|
}
|
|
}
|
|
|
|
return $persons;
|
|
}
|
|
}
|