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.

BaseRepository.php 1.9KB

4 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. <?php
  2. namespace Lc\ShopBundle\Repository;
  3. use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepositoryInterface;
  4. use Doctrine\ORM\EntityManager;
  5. use Doctrine\ORM\EntityRepository;
  6. use Symfony\Component\Security\Core\Security;
  7. class BaseRepository extends EntityRepository implements ServiceEntityRepositoryInterface
  8. {
  9. /**
  10. * @param string $entityClass The class name of the entity this repository manages
  11. */
  12. public function __construct(EntityManager $entityManager, $entityClass)
  13. {
  14. parent::__construct($entityManager, $entityManager->getClassMetadata($entityClass));
  15. }
  16. public function findAllOfflineAndDelete()
  17. {
  18. return $this->createQueryBuilder('e')
  19. ->andWhere('e.status < = 0')
  20. ->orderBy('e.status', "DESC")
  21. ->getQuery()
  22. ->getResult();
  23. }
  24. public function filterByMerchant($merchant){
  25. return $this->createQueryBuilder('e')
  26. ->where('e.merchant = :currentMerchant')
  27. ->setParameter('currentMerchant', $merchant->getId())
  28. ->getQuery()
  29. ->getResult();
  30. }
  31. public function findByMerchantQuery($merchant)
  32. {
  33. return $this->createQueryBuilder('e')
  34. ->where('e.merchant = :currentMerchant')
  35. ->setParameter('currentMerchant', $merchant->getId()) ;
  36. }
  37. public function findOneByDevAlias($devAlias, $merchant)
  38. {
  39. return $this->findByMerchantQuery($merchant)
  40. ->where('e.devAlias = :devAlias')
  41. ->andWhere('e.status = 1')
  42. ->setParameter('devAlias', $devAlias)
  43. ->getQuery()
  44. ->getResult();
  45. }
  46. }