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.

66 lines
2.1KB

  1. <?php
  2. namespace Lc\ShopBundle\Repository;
  3. use App\Entity\MerchantConfig;
  4. use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
  5. use Doctrine\Common\Persistence\ManagerRegistry;
  6. use Doctrine\ORM\EntityManager;
  7. use Lc\ShopBundle\Context\MerchantConfigInterface;
  8. use Lc\ShopBundle\Repository\BaseRepository;
  9. use Symfony\Component\Security\Core\Security;
  10. /**
  11. * @method MerchantConfig|null find($id, $lockMode = null, $lockVersion = null)
  12. * @method MerchantConfig|null findOneBy(array $criteria, array $orderBy = null)
  13. * @method MerchantConfig[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
  14. */
  15. class MerchantConfigRepository extends BaseRepository
  16. {
  17. protected $security ;
  18. public function __construct(EntityManager $entityManager, Security $security)
  19. {
  20. $this->security = $security ;
  21. parent::__construct($entityManager, MerchantConfigInterface::class);
  22. }
  23. public function findAll()
  24. {
  25. return $this->createQueryBuilder('m')
  26. ->andWhere('m.merchant = :currentMerchant')
  27. ->setParameter('currentMerchant', $this->security->getUser()->getMerchant()->getId())
  28. ->getQuery()
  29. ->getResult();
  30. }
  31. // /**
  32. // * @return MerchantConfig[] Returns an array of MerchantConfig objects
  33. // */
  34. /*
  35. public function findByExampleField($value)
  36. {
  37. return $this->createQueryBuilder('m')
  38. ->andWhere('m.exampleField = :val')
  39. ->setParameter('val', $value)
  40. ->orderBy('m.id', 'ASC')
  41. ->setMaxResults(10)
  42. ->getQuery()
  43. ->getResult()
  44. ;
  45. }
  46. */
  47. /*
  48. public function findOneBySomeField($value): ?MerchantConfig
  49. {
  50. return $this->createQueryBuilder('m')
  51. ->andWhere('m.exampleField = :val')
  52. ->setParameter('val', $value)
  53. ->getQuery()
  54. ->getOneOrNullResult()
  55. ;
  56. }
  57. */
  58. }