mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-07 18:44:08 +00:00
Merge branch 'fix-missing-dependency' into 'master'
Fix repositories - add typing - add missing methods - remove obsolete phpdoc See merge request Chill-Projet/chill-bundles!60
This commit is contained in:
commit
e4d1b951a3
@ -32,7 +32,7 @@ use Symfony\Component\Serializer\Annotation\DiscriminatorMap;
|
||||
use Symfony\Component\Serializer\Annotation\Groups;
|
||||
|
||||
/**
|
||||
* @ORM\Entity(repositoryClass=ResourceRepository::class)
|
||||
* @ORM\Entity
|
||||
* @ORM\Table(name="chill_person_accompanying_period_resource")
|
||||
* @DiscriminatorMap(typeProperty="type", mapping={
|
||||
* "accompanying_period_resource"=Resource::class
|
||||
|
@ -27,46 +27,41 @@ use Doctrine\ORM\EntityManagerInterface;
|
||||
use Doctrine\ORM\EntityRepository;
|
||||
use Doctrine\ORM\Query\ResultSetMappingBuilder;
|
||||
|
||||
/**
|
||||
* Class ClosingMotiveRepository
|
||||
* Entity repository for closing motives
|
||||
*
|
||||
* @package Chill\PersonBundle\Repository
|
||||
*/
|
||||
final class ClosingMotiveRepository
|
||||
{
|
||||
private EntityRepository $repository;
|
||||
|
||||
private EntityManagerInterface $entityManager;
|
||||
|
||||
public function __construct(EntityManagerInterface $entityManager)
|
||||
{
|
||||
$this->entityManager = $entityManager;
|
||||
$this->repository = $entityManager->getRepository(ClosingMotive::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param bool $onlyLeaf
|
||||
* @return mixed
|
||||
*/
|
||||
public function getActiveClosingMotive(bool $onlyLeaf = true)
|
||||
{
|
||||
$rsm = new ResultSetMappingBuilder($this->repository->getEntityManager());
|
||||
$rsm = new ResultSetMappingBuilder($this->entityManager);
|
||||
$rsm->addRootEntityFromClassMetadata($this->repository->getClassName(), 'cm');
|
||||
|
||||
$sql = "SELECT ".(string) $rsm."
|
||||
$sql = "SELECT " . (string) $rsm . "
|
||||
FROM chill_person_accompanying_period_closingmotive AS cm
|
||||
WHERE
|
||||
active IS TRUE ";
|
||||
|
||||
|
||||
if ($onlyLeaf) {
|
||||
$sql .= "AND cm.id NOT IN (
|
||||
SELECT DISTINCT parent_id FROM chill_person_accompanying_period_closingmotive WHERE parent_id IS NOT NULL
|
||||
)";
|
||||
}
|
||||
|
||||
|
||||
$sql .= " ORDER BY cm.ordering ASC";
|
||||
|
||||
return $this
|
||||
->repository
|
||||
->getEntityManager()
|
||||
->entityManager
|
||||
->createNativeQuery($sql, $rsm)
|
||||
->getResult();
|
||||
}
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -24,21 +24,19 @@ namespace Chill\PersonBundle\Repository\AccompanyingPeriod;
|
||||
|
||||
use Chill\PersonBundle\Entity\AccompanyingPeriod\Resource;
|
||||
use Doctrine\ORM\EntityRepository;
|
||||
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
|
||||
use Doctrine\Persistence\ManagerRegistry;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
|
||||
/**
|
||||
* @method Resource|null find($id, $lockMode = null, $lockVersion = null)
|
||||
* @method Resource|null findOneBy(array $criteria, array $orderBy = null)
|
||||
* @method Resource[] findAll()
|
||||
* @method Resource[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
|
||||
*/
|
||||
final class ResourceRepository extends ServiceEntityRepository
|
||||
final class ResourceRepository
|
||||
{
|
||||
private EntityRepository $repository;
|
||||
|
||||
public function __construct(ManagerRegistry $registry)
|
||||
public function __construct(EntityManagerInterface $entityManager)
|
||||
{
|
||||
parent::__construct($registry, Resource::class);
|
||||
$this->repository = $entityManager->getRepository(Resource::class);
|
||||
}
|
||||
|
||||
public function find($id, $lockMode = null, $lockVersion = null): ?Resource
|
||||
{
|
||||
return $this->repository->find($id, $lockMode, $lockVersion);
|
||||
}
|
||||
}
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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()
|
||||
;
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
@ -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()
|
||||
;
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
@ -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;
|
||||
|
@ -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();
|
||||
|
@ -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'));
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
Loading…
x
Reference in New Issue
Block a user