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.

43 lines
1.0KB

  1. <?php
  2. namespace Lc\CaracoleBundle\Repository\Product;
  3. use Knp\Component\Pager\PaginatorInterface;
  4. use Lc\CaracoleBundle\Repository\SectionRepositoryQueryTrait;
  5. use Lc\SovBundle\Doctrine\EntityInterface;
  6. use Lc\SovBundle\Repository\AbstractRepositoryQuery;
  7. class ProductCategoryRepositoryQuery extends AbstractRepositoryQuery
  8. {
  9. use SectionRepositoryQueryTrait;
  10. protected $isJoinProductFamilies = false;
  11. public function __construct(ProductCategoryRepository $repository, PaginatorInterface $paginator)
  12. {
  13. parent::__construct($repository, 'productCategory', $paginator);
  14. }
  15. public function joinProductFamilies(): self
  16. {
  17. if (!$this->isJoinProductFamilies) {
  18. $this->isJoinProductFamilies = true;
  19. return $this
  20. ->innerJoin('.productFamilies', 'productFamilies');
  21. }
  22. return $this;
  23. }
  24. public function hasProductFamilyOnline(): self
  25. {
  26. $this->joinProductFamilies();
  27. return $this->andWhere('productFamilies.status = 1');
  28. }
  29. }