TemplateSystemRepository.php 915 B

12345678910111213141516171819202122232425262728293031
  1. <?php
  2. namespace AppBundle\Entity\Message\Repository;
  3. use Doctrine\ORM\EntityRepository;
  4. /**
  5. * Description of TemplateSystemRepository
  6. *
  7. * @author sebastienhupin
  8. */
  9. class TemplateSystemRepository extends EntityRepository {
  10. /**
  11. * @param string $templateName
  12. * @param int $organizationId
  13. * @return mixed
  14. * @throws \Doctrine\ORM\NonUniqueResultException
  15. */
  16. public function findByTemplateName(string $templateName, int $organizationId) {
  17. $queryBuilder = $this->createQueryBuilder('o');
  18. $queryBuilder
  19. ->innerJoin('o.organization', 'organization')
  20. ->andWhere('o.template = :template')
  21. ->andWhere('organization.id = :orgnizationId')
  22. ->setParameter('template', $templateName)
  23. ->setParameter('orgnizationId', $organizationId)
  24. ;
  25. return $queryBuilder->getQuery()->getOneOrNullResult();
  26. }
  27. }