You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

44 line
1.5KB

  1. <?php
  2. namespace Lc\ShopBundle\Repository;
  3. use Lc\ShopBundle\Context\DefaultRepositoryInterface;
  4. use Lc\ShopBundle\Context\UserInterface;
  5. /**
  6. * @method UserInterface|null find($id, $lockMode = null, $lockVersion = null)
  7. * @method UserInterface|null findOneBy(array $criteria, array $orderBy = null)
  8. * @method UserInterface[] findAll()
  9. * @method UserInterface[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
  10. */
  11. class UserRepository extends BaseRepository implements DefaultRepositoryInterface
  12. {
  13. public function getInterfaceClass()
  14. {
  15. return UserInterface::class;
  16. }
  17. public function findAllByNewsletter($newsletter)
  18. {
  19. return $this->createQueryBuilder('e')
  20. ->where(':newsletter MEMBER OF e.newsletters')
  21. ->setParameter('newsletter', $newsletter->getId())
  22. ->andWhere('e.enabled = 1')
  23. ->innerJoin('e.userMerchants', 'um')
  24. ->andWhere('um.merchant = :merchant AND um.active = 1')
  25. ->setParameter('merchant', $newsletter->getMerchant())
  26. ->getQuery()
  27. ->getResult();
  28. }
  29. public function findByRole($role)
  30. {
  31. $qb = $this->createQueryBuilder('u')
  32. ->where('u.roles LIKE :roles')
  33. ->setParameter('roles', '%"' . $role . '"%');
  34. return $qb->getQuery()->getResult();
  35. }
  36. }