|
- <?php
-
- namespace Lc\CaracoleBundle\Repository\Reduction;
-
- use Lc\CaracoleBundle\Model\Product\ProductFamilyInterface;
- use Lc\CaracoleBundle\Repository\MerchantStoreTrait;
- use Lc\CaracoleBundle\Repository\AbstractStore;
- use Lc\SovBundle\Model\User\UserInterface;
- use Lc\SovBundle\Repository\RepositoryQueryInterface;
-
- class ReductionCatalogStore extends AbstractStore
- {
- use MerchantStoreTrait;
-
- protected ReductionCatalogRepositoryQuery $query;
-
- public function __construct(ReductionCatalogRepositoryQuery $query)
- {
- $this->query = $query;
- }
-
- public function orderByDefault(RepositoryQueryInterface $query): RepositoryQueryInterface
- {
- $query->orderBy('id');
- return $query;
- }
-
- public function filtersDefault(RepositoryQueryInterface $query): RepositoryQueryInterface
- {
- $this->addFilterByMerchantRequired($query);
- $query->filterIsOnlineAndOffline();
- return $query;
- }
-
- public function relationsDefault(RepositoryQueryInterface $query): RepositoryQueryInterface
- {
- return $query;
- }
-
- public function getByProductFamily(ProductFamilyInterface $productFamily, $query = null)
- {
- $query = $this->createDefaultQuery($query);
- $query->filterProductFamily($productFamily);
- return $query->findOne();
- }
-
-
- //Toutes les reductionCatalog d'un utilisateur inter/merchant
- public function getByUserOutOfContext(UserInterface $user, $query = null)
- {
- $query = $this->createQuery($query);
- $query->filterIsOnlineAndOffline();
- $query->filterByUser($user);
- return $query->find();
- }
- }
|