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.

74 satır
2.3KB

  1. <?php
  2. namespace Lc\ShopBundle\Repository;
  3. use Doctrine\Common\Persistence\ManagerRegistry;
  4. use Doctrine\ORM\EntityManager;
  5. use Doctrine\ORM\QueryBuilder;
  6. use Lc\ShopBundle\Context\ProductCategoryInterface;
  7. /**
  8. * @method ProductCategoryInterface|null find($id, $lockMode = null, $lockVersion = null)
  9. * @method ProductCategoryInterface|null findOneBy(array $criteria, array $orderBy = null)
  10. * @method ProductCategoryInterface[] findAll()
  11. * @method ProductCategoryInterface[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
  12. */
  13. class ProductCategoryRepository extends BaseRepository
  14. {
  15. public function __construct(EntityManager $entityManager)
  16. {
  17. parent::__construct($entityManager, ProductCategoryInterface::class);
  18. }
  19. public static function adminQueryBuilderForTree(BaseRepository $e): QueryBuilder
  20. {
  21. return $e->createQueryBuilder('e')
  22. ->where('e.parent is NULL')
  23. ->andWhere('e.status >= 0')
  24. ->orderBy('e.position', 'ASC');
  25. }
  26. public function findAllParents()
  27. {
  28. return $this->createQueryBuilder('e')
  29. ->where('e.parent is NULL')
  30. ->andWhere('e.status >= 0')
  31. ->orderBy('e.position', 'ASC')
  32. ->getQuery()
  33. ->getResult();
  34. }
  35. // /**
  36. // * @return ProductCategory[] Returns an array of ProductCategory objects
  37. // */
  38. /*
  39. public function findByExampleField($value)
  40. {
  41. return $this->createQueryBuilder('p')
  42. ->andWhere('p.exampleField = :val')
  43. ->setParameter('val', $value)
  44. ->orderBy('p.id', 'ASC')
  45. ->setMaxResults(10)
  46. ->getQuery()
  47. ->getResult()
  48. ;
  49. }
  50. */
  51. /*
  52. public function findOneBySomeField($value): ?ProductCategory
  53. {
  54. return $this->createQueryBuilder('p')
  55. ->andWhere('p.exampleField = :val')
  56. ->setParameter('val', $value)
  57. ->getQuery()
  58. ->getOneOrNullResult()
  59. ;
  60. }
  61. */
  62. }