OrganizationAddressPostalRepository.php 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. <?php
  2. declare(strict_types=1);
  3. namespace App\Repository\Organization;
  4. use App\Entity\Organization\Organization;
  5. use App\Entity\Organization\OrganizationAddressPostal;
  6. use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
  7. use Doctrine\Persistence\ManagerRegistry;
  8. /**
  9. * @method OrganizationAddressPostal|null find($id, $lockMode = null, $lockVersion = null)
  10. * @method OrganizationAddressPostal|null findOneBy(array $criteria, array $orderBy = null)
  11. * @method OrganizationAddressPostal[] findAll()
  12. * @method OrganizationAddressPostal[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
  13. */
  14. class OrganizationAddressPostalRepository extends ServiceEntityRepository
  15. {
  16. public function __construct(ManagerRegistry $registry)
  17. {
  18. parent::__construct($registry, OrganizationAddressPostal::class);
  19. }
  20. /**
  21. * Récupération des adresses postal d'une organization et d'un type précis
  22. * @param String $type
  23. * @param Organization $organization
  24. * @return array|null
  25. */
  26. public function getByType(String $type, Organization $organization): array | null{
  27. return $this->createQueryBuilder('organizationAddressPostal')
  28. ->where('organizationAddressPostal.type = :type')
  29. ->andWhere('organizationAddressPostal.organization = :organization')
  30. ->setParameter('type', $type)
  31. ->setParameter('organization', $organization)
  32. ->getQuery()
  33. ->getResult()
  34. ;
  35. }
  36. }