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.

51 lines
1.3KB

  1. <?php
  2. namespace Lc\CaracoleBundle\Repository\Reduction;
  3. use Lc\CaracoleBundle\Model\Product\ProductFamilyInterface;
  4. use Lc\CaracoleBundle\Repository\SectionStoreTrait;
  5. use Lc\SovBundle\Repository\AbstractStore;
  6. use Lc\SovBundle\Repository\RepositoryQueryInterface;
  7. class ReductionCatalogStore extends AbstractStore
  8. {
  9. use SectionStoreTrait;
  10. protected ReductionCatalogRepositoryQuery $query;
  11. public function __construct(ReductionCatalogRepositoryQuery $query)
  12. {
  13. $this->query = $query;
  14. }
  15. public function orderByDefault(RepositoryQueryInterface $query): RepositoryQueryInterface
  16. {
  17. $query->orderBy('id');
  18. return $query;
  19. }
  20. public function filtersDefault(RepositoryQueryInterface $query): RepositoryQueryInterface
  21. {
  22. if($this->section) {
  23. $query->filterBySection($this->section);
  24. }
  25. $query->filterIsOnlineAndOffline();
  26. return $query;
  27. }
  28. public function relationsDefault(RepositoryQueryInterface $query): RepositoryQueryInterface
  29. {
  30. return $query;
  31. }
  32. public function getByProductFamily(ProductFamilyInterface $productFamily, $query = null)
  33. {
  34. $query = $this->createDefaultQuery($query);
  35. $query
  36. ->filterProductFamily($productFamily);
  37. return $query->findOne();
  38. }
  39. }