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

87 行
2.3KB

  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. $this->addFilterByMerchantOptionnal($query);
  27. return $query;
  28. }
  29. public function relationsDefault(RepositoryQueryInterface $query): RepositoryQueryInterface
  30. {
  31. return $query;
  32. }
  33. public function getOneBySlug(string $slug, bool $isOnline = true, $query = null)
  34. {
  35. $query = $this->createDefaultQuery($query);
  36. $query->filterBySlug($slug);
  37. if ($isOnline) {
  38. $query->filterIsOnline();
  39. }
  40. return $query->findOne();
  41. }
  42. public function getOneDefault($query = null)
  43. {
  44. $query = $this->createDefaultQuery($query);
  45. $query->filterByIsDefault(true);
  46. return $query->findOne();
  47. }
  48. // getSection
  49. public function getOneOnlineByDevAlias(string $devAlias, $query = null): ?SectionInterface
  50. {
  51. $section = parent::getOneOnlineByDevAlias($devAlias, $query);
  52. if (!$section) {
  53. throw new NotFoundHttpException('La section ' . $devAlias . ' est introuvable');
  54. }
  55. return $section;
  56. }
  57. public function countOpenDays(SectionInterface $section, $query = null): int
  58. {
  59. // @TODO : à implémenter avec le nouveau système d'ouverture des commandes
  60. }
  61. public function getOnlineWithoutCommon($query = null)
  62. {
  63. $query = $this->createDefaultQuery($query);
  64. $query->filterByIsCommon(false);
  65. return $query->find();
  66. }
  67. }