|
- <?php
-
- namespace Lc\CaracoleBundle\Repository\Section;
-
- use Lc\CaracoleBundle\Model\Section\SectionInterface;
- use Lc\CaracoleBundle\Repository\MerchantStoreTrait;
- use Lc\CaracoleBundle\Repository\Order\OrderShopStore;
- use Lc\CaracoleBundle\Repository\AbstractStore;
- use Lc\SovBundle\Repository\RepositoryQueryInterface;
- use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
-
- class SectionStore extends AbstractStore
- {
- use MerchantStoreTrait;
-
- protected SectionRepositoryQuery $query;
- protected OrderShopStore $orderShopStore;
-
- public function __construct(SectionRepositoryQuery $query)
- {
- $this->query = $query;
- }
-
- public function orderByDefault(RepositoryQueryInterface $query): RepositoryQueryInterface
- {
- $query->orderBy('position');
- return $query;
- }
-
- public function filtersDefault(RepositoryQueryInterface $query): RepositoryQueryInterface
- {
- $this->addFilterByMerchantOptionnal($query);
- return $query;
- }
-
- public function relationsDefault(RepositoryQueryInterface $query): RepositoryQueryInterface
- {
- return $query;
- }
-
- public function getOneBySlug(string $slug, bool $isOnline = true, $query = null)
- {
- $query = $this->createDefaultQuery($query);
-
- $query->filterBySlug($slug);
-
- if ($isOnline) {
- $query->filterIsOnline();
- }
-
- return $query->findOne();
- }
-
- public function getOneDefault($query = null)
- {
- $query = $this->createDefaultQuery($query);
- $query->filterByIsDefault(true);
- return $query->findOne();
- }
-
- // getSection
- public function getOneOnlineByDevAlias(string $devAlias, $query = null): ?SectionInterface
- {
- $section = parent::getOneOnlineByDevAlias($devAlias, $query);
-
- if (!$section) {
- throw new NotFoundHttpException('La section ' . $devAlias . ' est introuvable');
- }
-
- return $section;
- }
-
- public function countOpenDays(SectionInterface $section, $query = null): int
- {
- // @TODO : à implémenter avec le nouveau système d'ouverture des commandes
- }
-
-
- }
|