選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

56 行
1.6KB

  1. <?php
  2. namespace Lc\CaracoleBundle\Repository\Reduction;
  3. use Lc\CaracoleBundle\Model\Product\ProductFamilyInterface;
  4. use Lc\CaracoleBundle\Repository\MerchantStoreTrait;
  5. use Lc\CaracoleBundle\Repository\AbstractStore;
  6. use Lc\SovBundle\Model\User\UserInterface;
  7. use Lc\SovBundle\Repository\RepositoryQueryInterface;
  8. class ReductionCatalogStore extends AbstractStore
  9. {
  10. use MerchantStoreTrait;
  11. protected ReductionCatalogRepositoryQuery $query;
  12. public function __construct(ReductionCatalogRepositoryQuery $query)
  13. {
  14. $this->query = $query;
  15. }
  16. public function orderByDefault(RepositoryQueryInterface $query): RepositoryQueryInterface
  17. {
  18. $query->orderBy('id');
  19. return $query;
  20. }
  21. public function filtersDefault(RepositoryQueryInterface $query): RepositoryQueryInterface
  22. {
  23. $this->addFilterByMerchantRequired($query);
  24. $query->filterIsOnlineAndOffline();
  25. return $query;
  26. }
  27. public function relationsDefault(RepositoryQueryInterface $query): RepositoryQueryInterface
  28. {
  29. return $query;
  30. }
  31. public function getByProductFamily(ProductFamilyInterface $productFamily, $query = null)
  32. {
  33. $query = $this->createDefaultQuery($query);
  34. $query->filterProductFamily($productFamily);
  35. return $query->findOne();
  36. }
  37. //Toutes les reductionCatalog d'un utilisateur inter/merchant
  38. public function getByUserOutOfContext(UserInterface $user, $query = null)
  39. {
  40. $query = $this->createQuery($query);
  41. $query->filterIsOnlineAndOffline();
  42. $query->filterByUser($user);
  43. return $query->find();
  44. }
  45. }