|
- <?php
-
- namespace Lc\CaracoleBundle\Repository\Section;
-
- use Lc\CaracoleBundle\Model\Merchant\MerchantInterface;
- use Lc\CaracoleBundle\Model\Section\SectionInterface;
- use Lc\CaracoleBundle\Repository\MerchantStoreTrait;
- use Lc\CaracoleBundle\Repository\Order\OrderShopStore;
- use Lc\SovBundle\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
- {
- $query->filterByMerchant($this->merchant);
- return $query;
- }
-
- public function relationsDefault(RepositoryQueryInterface $query): RepositoryQueryInterface
- {
- return $query;
- }
-
- public function getOneDefault($query = null)
- {
- $query = $this->createDefaultQuery($query);
- $query->filterByIsDefault(true);
- return $query->findOne();
- }
-
- // getSection
- public function getOneByDevAlias(string $devAlias, bool $isOnline = true, $query = null): ?SectionInterface
- {
- $section = parent::getOneByDevAlias($devAlias, $isOnline, $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
- }
-
- }
|