diff --git a/src/Bundle/ChillPersonBundle/Repository/AccompanyingPeriod/CommentRepository.php b/src/Bundle/ChillPersonBundle/Repository/AccompanyingPeriod/CommentRepository.php index aca7a9c68..b3a20780e 100644 --- a/src/Bundle/ChillPersonBundle/Repository/AccompanyingPeriod/CommentRepository.php +++ b/src/Bundle/ChillPersonBundle/Repository/AccompanyingPeriod/CommentRepository.php @@ -26,12 +26,6 @@ use Chill\PersonBundle\Entity\AccompanyingPeriod\Comment; use Doctrine\ORM\EntityManagerInterface; use Doctrine\ORM\EntityRepository; -/** - * @method Comment|null find($id, $lockMode = null, $lockVersion = null) - * @method Comment|null findOneBy(array $criteria, array $orderBy = null) - * @method Comment[] findAll() - * @method Comment[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null) - */ final class CommentRepository { private EntityRepository $repository; diff --git a/src/Bundle/ChillPersonBundle/Repository/AccompanyingPeriod/OriginRepository.php b/src/Bundle/ChillPersonBundle/Repository/AccompanyingPeriod/OriginRepository.php index c2851b851..596bfc2ee 100644 --- a/src/Bundle/ChillPersonBundle/Repository/AccompanyingPeriod/OriginRepository.php +++ b/src/Bundle/ChillPersonBundle/Repository/AccompanyingPeriod/OriginRepository.php @@ -26,12 +26,6 @@ use Chill\PersonBundle\Entity\AccompanyingPeriod\Origin; use Doctrine\ORM\EntityManagerInterface; use Doctrine\ORM\EntityRepository; -/** - * @method Origin|null find($id, $lockMode = null, $lockVersion = null) - * @method Origin|null findOneBy(array $criteria, array $orderBy = null) - * @method Origin[] findAll() - * @method Origin[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null) - */ final class OriginRepository { private EntityRepository $repository; diff --git a/src/Bundle/ChillPersonBundle/Repository/AccompanyingPeriodParticipationRepository.php b/src/Bundle/ChillPersonBundle/Repository/AccompanyingPeriodParticipationRepository.php index 0f157ed42..f902c7cc8 100644 --- a/src/Bundle/ChillPersonBundle/Repository/AccompanyingPeriodParticipationRepository.php +++ b/src/Bundle/ChillPersonBundle/Repository/AccompanyingPeriodParticipationRepository.php @@ -26,12 +26,6 @@ use Chill\PersonBundle\Entity\AccompanyingPeriodParticipation; use Doctrine\ORM\EntityManagerInterface; use Doctrine\ORM\EntityRepository; -/** - * @method AccompanyingPeriodParticipation|null find($id, $lockMode = null, $lockVersion = null) - * @method AccompanyingPeriodParticipation|null findOneBy(array $criteria, array $orderBy = null) - * @method AccompanyingPeriodParticipation[] findAll() - * @method AccompanyingPeriodParticipation[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null) - */ final class AccompanyingPeriodParticipationRepository { private EntityRepository $repository; diff --git a/src/Bundle/ChillPersonBundle/Repository/AccompanyingPeriodRepository.php b/src/Bundle/ChillPersonBundle/Repository/AccompanyingPeriodRepository.php index 07aa0a55f..c2a8299fc 100644 --- a/src/Bundle/ChillPersonBundle/Repository/AccompanyingPeriodRepository.php +++ b/src/Bundle/ChillPersonBundle/Repository/AccompanyingPeriodRepository.php @@ -26,12 +26,6 @@ use Chill\PersonBundle\Entity\AccompanyingPeriod; use Doctrine\ORM\EntityManagerInterface; use Doctrine\ORM\EntityRepository; -/** - * @method AccompanyingPeriod|null find($id, $lockMode = null, $lockVersion = null) - * @method AccompanyingPeriod|null findOneBy(array $criteria, array $orderBy = null) - * @method AccompanyingPeriod[] findAll() - * @method AccompanyingPeriod[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null) - */ final class AccompanyingPeriodRepository { private EntityRepository $repository; diff --git a/src/Bundle/ChillPersonBundle/Repository/Household/HouseholdMembersRepository.php b/src/Bundle/ChillPersonBundle/Repository/Household/HouseholdMembersRepository.php index b11d3d93a..1a634f451 100644 --- a/src/Bundle/ChillPersonBundle/Repository/Household/HouseholdMembersRepository.php +++ b/src/Bundle/ChillPersonBundle/Repository/Household/HouseholdMembersRepository.php @@ -6,12 +6,6 @@ use Chill\PersonBundle\Entity\Household\HouseholdMembers; use Doctrine\ORM\EntityManagerInterface; use Doctrine\ORM\EntityRepository; -/** - * @method HouseholdMembers|null find($id, $lockMode = null, $lockVersion = null) - * @method HouseholdMembers|null findOneBy(array $criteria, array $orderBy = null) - * @method HouseholdMembers[] findAll() - * @method HouseholdMembers[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null) - */ final class HouseholdMembersRepository { private EntityRepository $repository; @@ -20,33 +14,4 @@ final class HouseholdMembersRepository { $this->repository = $entityManager->getRepository(HouseholdMembers::class); } - - // /** - // * @return HouseholdMembers[] Returns an array of HouseholdMembers objects - // */ - /* - public function findByExampleField($value) - { - return $this->createQueryBuilder('h') - ->andWhere('h.exampleField = :val') - ->setParameter('val', $value) - ->orderBy('h.id', 'ASC') - ->setMaxResults(10) - ->getQuery() - ->getResult() - ; - } - */ - - /* - public function findOneBySomeField($value): ?HouseholdMembers - { - return $this->createQueryBuilder('h') - ->andWhere('h.exampleField = :val') - ->setParameter('val', $value) - ->getQuery() - ->getOneOrNullResult() - ; - } - */ } diff --git a/src/Bundle/ChillPersonBundle/Repository/Household/HouseholdRepository.php b/src/Bundle/ChillPersonBundle/Repository/Household/HouseholdRepository.php index 78a68f56d..b7a8816b3 100644 --- a/src/Bundle/ChillPersonBundle/Repository/Household/HouseholdRepository.php +++ b/src/Bundle/ChillPersonBundle/Repository/Household/HouseholdRepository.php @@ -6,12 +6,6 @@ use Chill\PersonBundle\Entity\Household\Household; use Doctrine\ORM\EntityManagerInterface; use Doctrine\ORM\EntityRepository; -/** - * @method Household|null find($id, $lockMode = null, $lockVersion = null) - * @method Household|null findOneBy(array $criteria, array $orderBy = null) - * @method Household[] findAll() - * @method Household[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null) - */ final class HouseholdRepository { private EntityRepository $repository; @@ -20,33 +14,4 @@ final class HouseholdRepository { $this->repository = $entityManager->getRepository(Household::class); } - - // /** - // * @return Household[] Returns an array of Household objects - // */ - /* - public function findByExampleField($value) - { - return $this->createQueryBuilder('h') - ->andWhere('h.exampleField = :val') - ->setParameter('val', $value) - ->orderBy('h.id', 'ASC') - ->setMaxResults(10) - ->getQuery() - ->getResult() - ; - } - */ - - /* - public function findOneBySomeField($value): ?Household - { - return $this->createQueryBuilder('h') - ->andWhere('h.exampleField = :val') - ->setParameter('val', $value) - ->getQuery() - ->getOneOrNullResult() - ; - } - */ } diff --git a/src/Bundle/ChillPersonBundle/Repository/PersonAltNameRepository.php b/src/Bundle/ChillPersonBundle/Repository/PersonAltNameRepository.php index c5dea689a..eed330c8a 100644 --- a/src/Bundle/ChillPersonBundle/Repository/PersonAltNameRepository.php +++ b/src/Bundle/ChillPersonBundle/Repository/PersonAltNameRepository.php @@ -6,12 +6,6 @@ use Chill\PersonBundle\Entity\PersonAltName; use Doctrine\ORM\EntityManagerInterface; use Doctrine\ORM\EntityRepository; -/** - * PersonAltNameRepository - * - * This class was generated by the Doctrine ORM. Add your own custom - * repository methods below. - */ final class PersonAltNameRepository { private EntityRepository $repository; diff --git a/src/Bundle/ChillPersonBundle/Repository/PersonNotDuplicateRepository.php b/src/Bundle/ChillPersonBundle/Repository/PersonNotDuplicateRepository.php index 989baaeec..b899f06c1 100644 --- a/src/Bundle/ChillPersonBundle/Repository/PersonNotDuplicateRepository.php +++ b/src/Bundle/ChillPersonBundle/Repository/PersonNotDuplicateRepository.php @@ -7,11 +7,6 @@ use Chill\PersonBundle\Entity\PersonNotDuplicate; use Doctrine\ORM\EntityManagerInterface; use Doctrine\ORM\EntityRepository; -/** - * Class PersonNotDuplicateRepository - * - * @package Chill\PersonBundle\Repository - */ final class PersonNotDuplicateRepository { private EntityRepository $repository; @@ -21,12 +16,7 @@ final class PersonNotDuplicateRepository $this->repository = $entityManager->getRepository(PersonNotDuplicate::class); } - /** - * @param \Chill\PersonBundle\Entity\Person $person - * - * @return array - */ - public function findNotDuplicatePerson(Person $person) + public function findNotDuplicatePerson(Person $person): array { $qb = $this->repository->createQueryBuilder('pnd'); $qb->select('pnd') @@ -36,6 +26,7 @@ final class PersonNotDuplicateRepository $result = $qb->getQuery()->getResult(); $persons = []; + foreach ($result as $row) { if ($row->getPerson1() === $person) { $persons[] = $row->getPerson2(); diff --git a/src/Bundle/ChillPersonBundle/Repository/PersonRepository.php b/src/Bundle/ChillPersonBundle/Repository/PersonRepository.php index 12733a668..fdd0f054e 100644 --- a/src/Bundle/ChillPersonBundle/Repository/PersonRepository.php +++ b/src/Bundle/ChillPersonBundle/Repository/PersonRepository.php @@ -32,105 +32,88 @@ final class PersonRepository $this->repository = $entityManager->getRepository(Person::class); } - public function find($id, $lockMode = null, $lockVersion = null) + public function find($id, $lockMode = null, $lockVersion = null): ?Person { return $this->repository->find($id, $lockMode, $lockVersion); } /** - * @param string $phonenumber * @param $centers * @param $firstResult * @param $maxResults - * @param array $only * @return mixed * @throws \Exception */ public function findByPhone( - string $phonenumber, - $centers, + string $phonenumber, + $centers, $firstResult, $maxResults, array $only = ['mobile', 'phone'] ) { $qb = $this->repository->createQueryBuilder('p'); $qb->select('p'); - + $this->addByCenters($qb, $centers); $this->addPhoneNumber($qb, $phonenumber, $only); - + $qb->setFirstResult($firstResult) ->setMaxResults($maxResults) ; - + return $qb->getQuery()->getResult(); } - + /** - * @param string $phonenumber * @param $centers - * @param array $only - * @return int * @throws \Doctrine\ORM\NoResultException * @throws \Doctrine\ORM\NonUniqueResultException */ public function countByPhone( - string $phonenumber, - $centers, + string $phonenumber, + $centers, array $only = ['mobile', 'phone'] - ): int - { + ): int { $qb = $this->repository->createQueryBuilder('p'); $qb->select('COUNT(p)'); - + $this->addByCenters($qb, $centers); $this->addPhoneNumber($qb, $phonenumber, $only); - + return $qb->getQuery()->getSingleScalarResult(); } - + /** - * @param QueryBuilder $qb - * @param string $phonenumber - * @param array $only * @throws \Exception */ - protected function addPhoneNumber(QueryBuilder $qb, string $phonenumber, array $only) + protected function addPhoneNumber(QueryBuilder $qb, string $phonenumber, array $only): void { if (count($only) === 0) { throw new \Exception("No array field to search"); } - + $phonenumber = $this->parsePhoneNumber($phonenumber); - + $orX = $qb->expr()->orX(); - + if (\in_array('mobile', $only)) { $orX->add($qb->expr()->like("REPLACE(p.mobilenumber, ' ', '')", ':phonenumber')); } if (\in_array('phone', $only)) { $orX->add($qb->expr()->like("REPLACE(p.phonenumber, ' ', '')", ':phonenumber')); } - + $qb->andWhere($orX); - + $qb->setParameter('phonenumber', '%'.$phonenumber.'%'); } - - /** - * @param $phonenumber - * @return string - */ - protected function parsePhoneNumber($phonenumber): string + + protected function parsePhoneNumber(string $phonenumber): string { return \str_replace(' ', '', $phonenumber); } - - /** - * @param QueryBuilder $qb - * @param array $centers - */ - protected function addByCenters(QueryBuilder $qb, array $centers) + + protected function addByCenters(QueryBuilder $qb, array $centers): void { if (count($centers) > 0) { $qb->andWhere($qb->expr()->in('p.center', ':centers')); diff --git a/src/Bundle/ChillPersonBundle/Repository/SocialWork/EvaluationRepository.php b/src/Bundle/ChillPersonBundle/Repository/SocialWork/EvaluationRepository.php index c9ab3c931..f554e4e8c 100644 --- a/src/Bundle/ChillPersonBundle/Repository/SocialWork/EvaluationRepository.php +++ b/src/Bundle/ChillPersonBundle/Repository/SocialWork/EvaluationRepository.php @@ -6,12 +6,6 @@ use Chill\PersonBundle\Entity\SocialWork\Evaluation; use Doctrine\ORM\EntityManagerInterface; use Doctrine\ORM\EntityRepository; -/** - * @method Evaluation|null find($id, $lockMode = null, $lockVersion = null) - * @method Evaluation|null findOneBy(array $criteria, array $orderBy = null) - * @method Evaluation[] findAll() - * @method Evaluation[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null) - */ final class EvaluationRepository { private EntityRepository $repository; diff --git a/src/Bundle/ChillPersonBundle/Repository/SocialWork/GoalRepository.php b/src/Bundle/ChillPersonBundle/Repository/SocialWork/GoalRepository.php index 30576b4ed..bd7c6a738 100644 --- a/src/Bundle/ChillPersonBundle/Repository/SocialWork/GoalRepository.php +++ b/src/Bundle/ChillPersonBundle/Repository/SocialWork/GoalRepository.php @@ -6,12 +6,6 @@ use Chill\PersonBundle\Entity\SocialWork\Goal; use Doctrine\ORM\EntityManagerInterface; use Doctrine\ORM\EntityRepository; -/** - * @method Goal|null find($id, $lockMode = null, $lockVersion = null) - * @method Goal|null findOneBy(array $criteria, array $orderBy = null) - * @method Goal[] findAll() - * @method Goal[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null) - */ final class GoalRepository { private EntityRepository $repository; diff --git a/src/Bundle/ChillPersonBundle/Repository/SocialWork/ResultRepository.php b/src/Bundle/ChillPersonBundle/Repository/SocialWork/ResultRepository.php index 004a2f82c..1c4d8d013 100644 --- a/src/Bundle/ChillPersonBundle/Repository/SocialWork/ResultRepository.php +++ b/src/Bundle/ChillPersonBundle/Repository/SocialWork/ResultRepository.php @@ -6,12 +6,6 @@ use Chill\PersonBundle\Entity\SocialWork\Result; use Doctrine\ORM\EntityManagerInterface; use Doctrine\ORM\EntityRepository; -/** - * @method Result|null find($id, $lockMode = null, $lockVersion = null) - * @method Result|null findOneBy(array $criteria, array $orderBy = null) - * @method Result[] findAll() - * @method Result[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null) - */ final class ResultRepository { private EntityRepository $repository; diff --git a/src/Bundle/ChillPersonBundle/Repository/SocialWork/SocialActionRepository.php b/src/Bundle/ChillPersonBundle/Repository/SocialWork/SocialActionRepository.php index cfa9adbd7..3c86d2397 100644 --- a/src/Bundle/ChillPersonBundle/Repository/SocialWork/SocialActionRepository.php +++ b/src/Bundle/ChillPersonBundle/Repository/SocialWork/SocialActionRepository.php @@ -6,12 +6,6 @@ use Chill\PersonBundle\Entity\SocialWork\SocialAction; use Doctrine\ORM\EntityManagerInterface; use Doctrine\ORM\EntityRepository; -/** - * @method SocialAction|null find($id, $lockMode = null, $lockVersion = null) - * @method SocialAction|null findOneBy(array $criteria, array $orderBy = null) - * @method SocialAction[] findAll() - * @method SocialAction[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null) - */ final class SocialActionRepository { private EntityRepository $repository; diff --git a/src/Bundle/ChillPersonBundle/Repository/SocialWork/SocialIssueRepository.php b/src/Bundle/ChillPersonBundle/Repository/SocialWork/SocialIssueRepository.php index 2f6eb3ba1..1100d8136 100644 --- a/src/Bundle/ChillPersonBundle/Repository/SocialWork/SocialIssueRepository.php +++ b/src/Bundle/ChillPersonBundle/Repository/SocialWork/SocialIssueRepository.php @@ -7,12 +7,6 @@ use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository; use Doctrine\ORM\EntityManagerInterface; use Doctrine\ORM\EntityRepository; -/** - * @method SocialIssue|null find($id, $lockMode = null, $lockVersion = null) - * @method SocialIssue|null findOneBy(array $criteria, array $orderBy = null) - * @method SocialIssue[] findAll() - * @method SocialIssue[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null) - */ final class SocialIssueRepository { private EntityRepository $repository;