|
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566 |
- <?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 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
- }
-
- }
|