| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061 |
- <?php
- declare(strict_types=1);
- namespace App\Repository\Core;
- use App\Entity\Core\ContactPoint;
- use App\Entity\Organization\Organization;
- use App\Entity\Person\Person;
- use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
- use Doctrine\Persistence\ManagerRegistry;
- /**
- * @method ContactPoint|null find($id, $lockMode = null, $lockVersion = null)
- * @method ContactPoint|null findOneBy(array $criteria, array $orderBy = null)
- * @method ContactPoint[] findAll()
- * @method ContactPoint[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
- */
- class ContactPointRepository extends ServiceEntityRepository
- {
- public function __construct(ManagerRegistry $registry)
- {
- parent::__construct($registry, ContactPoint::class);
- }
- /**
- * Récupération des points de contacts d'une organization et d'un type précis
- * @param String $type
- * @param Organization $organization
- * @return array|null
- */
- public function getByTypeAndOrganization(String $type, Organization $organization): array | null{
- return $this->createQueryBuilder('contact_point')
- ->innerJoin('contact_point.organization', 'organization')
- ->where('contact_point.contactType = :type')
- ->andWhere('organization.id = :organizationId')
- ->setParameter('type', $type)
- ->setParameter('organizationId', $organization->getId())
- ->getQuery()
- ->getResult()
- ;
- }
- /**
- * Récupération des points de contacts d'une person et d'un type précis
- * @param String $type
- * @param Person $person
- * @return array|null
- */
- public function getByTypeAndPerson(String $type, Person $person): array | null{
- return $this->createQueryBuilder('contact_point')
- ->innerJoin('contact_point.person', 'person')
- ->where('contact_point.contactType = :type')
- ->andWhere('person.id = :personId')
- ->setParameter('type', $type)
- ->setParameter('personId', $person->getId())
- ->getQuery()
- ->getResult()
- ;
- }
- }
|