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.

SectionStore.php 1.9KB

3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. <?php
  2. namespace Lc\CaracoleBundle\Repository\Section;
  3. use Lc\CaracoleBundle\Model\Merchant\MerchantInterface;
  4. use Lc\CaracoleBundle\Model\Section\SectionInterface;
  5. use Lc\CaracoleBundle\Repository\MerchantStoreTrait;
  6. use Lc\CaracoleBundle\Repository\Order\OrderShopStore;
  7. use Lc\SovBundle\Repository\AbstractStore;
  8. use Lc\SovBundle\Repository\RepositoryQueryInterface;
  9. use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
  10. class SectionStore extends AbstractStore
  11. {
  12. use MerchantStoreTrait;
  13. protected SectionRepositoryQuery $query;
  14. protected OrderShopStore $orderShopStore;
  15. public function __construct(SectionRepositoryQuery $query)
  16. {
  17. $this->query = $query;
  18. }
  19. public function orderByDefault(RepositoryQueryInterface $query): RepositoryQueryInterface
  20. {
  21. $query->orderBy('position');
  22. return $query;
  23. }
  24. public function filtersDefault(RepositoryQueryInterface $query): RepositoryQueryInterface
  25. {
  26. $query->filterByMerchant($this->merchant);
  27. return $query;
  28. }
  29. public function relationsDefault(RepositoryQueryInterface $query): RepositoryQueryInterface
  30. {
  31. return $query;
  32. }
  33. public function getOneDefault($query = null)
  34. {
  35. $query = $this->createDefaultQuery($query);
  36. $query->filterByIsDefault(true);
  37. return $query->findOne();
  38. }
  39. // getSection
  40. public function getOneOnlineByDevAlias(string $devAlias, $query = null): ?SectionInterface
  41. {
  42. $section = parent::getOneOnlineByDevAlias($devAlias, $query);
  43. if (!$section) {
  44. throw new NotFoundHttpException('La section ' . $devAlias . ' est introuvable');
  45. }
  46. return $section;
  47. }
  48. public function countOpenDays(SectionInterface $section, $query = null): int
  49. {
  50. // @TODO : à implémenter avec le nouveau système d'ouverture des commandes
  51. }
  52. }