Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

80 lines
2.1KB

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