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.

ReductionCartStore.php 1.9KB

3 yıl önce
3 yıl önce
3 yıl önce
3 yıl önce
3 yıl önce
3 yıl önce
3 yıl önce
3 yıl önce
3 yıl önce
3 yıl önce
3 yıl önce
3 yıl önce
3 yıl önce
3 yıl önce
3 yıl önce
3 yıl önce
3 yıl önce
3 yıl önce
3 yıl önce
3 yıl önce
3 yıl önce
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. <?php
  2. namespace Lc\CaracoleBundle\Repository\Reduction;
  3. use Lc\CaracoleBundle\Repository\SectionStoreTrait;
  4. use Lc\CaracoleBundle\Solver\Price\PriceSolver;
  5. use Lc\CaracoleBundle\Solver\Reduction\ReductionCartSolver;
  6. use Lc\CaracoleBundle\Repository\AbstractStore;
  7. use Lc\SovBundle\Repository\RepositoryQueryInterface;
  8. class ReductionCartStore extends AbstractStore
  9. {
  10. use SectionStoreTrait;
  11. protected ReductionCartRepositoryQuery $query;
  12. protected ReductionCartSolver $reductionCartSolver;
  13. protected PriceSolver $priceSolver;
  14. public function __construct(
  15. ReductionCartRepositoryQuery $query,
  16. ReductionCartSolver $reductionCartSolver,
  17. PriceSolver $priceSolver
  18. ) {
  19. $this->query = $query;
  20. $this->reductionCartSolver = $reductionCartSolver;
  21. $this->priceSolver = $priceSolver;
  22. }
  23. public function orderByDefault(RepositoryQueryInterface $query): RepositoryQueryInterface
  24. {
  25. $query->orderBy('id');
  26. return $query;
  27. }
  28. public function filtersDefault(RepositoryQueryInterface $query): RepositoryQueryInterface
  29. {
  30. if($this->section) {
  31. $query->filterBySection($this->section);
  32. }
  33. $query->filterIsOnlineAndOffline();
  34. return $query;
  35. }
  36. public function relationsDefault(RepositoryQueryInterface $query): RepositoryQueryInterface
  37. {
  38. return $query;
  39. }
  40. // getReductionCartByCode
  41. public function getByCode(string $code, $query = null)
  42. {
  43. $query = $this->createDefaultQuery($query);
  44. $query->filterByCode($code);
  45. $reductionCarts = $query->find();
  46. $findReductionCart = null;
  47. foreach ($reductionCarts as $reductionCart) {
  48. if ($reductionCart && in_array($code, $reductionCart->getCodes())) {
  49. $findReductionCart = $reductionCart;
  50. }
  51. }
  52. return $findReductionCart;
  53. }
  54. }