OrganizationAddressPostalRepository.php 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  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
  27. {
  28. return $this->createQueryBuilder('organizationAddressPostal')
  29. ->where('organizationAddressPostal.type = :type')
  30. ->andWhere('organizationAddressPostal.organization = :organization')
  31. ->setParameter('type', $type)
  32. ->setParameter('organization', $organization)
  33. ->getQuery()
  34. ->getResult()
  35. ;
  36. }
  37. }