|
- <?php
-
- namespace Lc\CaracoleBundle\Repository\Distribution;
-
- use App\Entity\Distribution\Distribution;
- use Lc\CaracoleBundle\Model\Section\SectionInterface;
- use Lc\CaracoleBundle\Repository\SectionStoreTrait;
- use Lc\SovBundle\Repository\AbstractStore;
- use Lc\SovBundle\Repository\RepositoryQueryInterface;
-
- class DistributionStore extends AbstractStore
- {
- use SectionStoreTrait;
-
- protected DistributionRepositoryQuery $query;
-
- public function __construct(DistributionRepositoryQuery $query)
- {
- $this->query = $query;
- }
-
- public function orderByDefault(RepositoryQueryInterface $query): RepositoryQueryInterface
- {
- $query->orderBy('id');
- return $query;
- }
-
- public function filtersDefault(RepositoryQueryInterface $query): RepositoryQueryInterface
- {
- $query->filterBySection($this->section);
- return $query;
- }
-
- public function relationsDefault(RepositoryQueryInterface $query): RepositoryQueryInterface
- {
- return $query;
- }
-
- public function getOneByCycleNumberYearAndSection(
- int $cycleNumber,
- int $year,
- SectionInterface $section
- ): ?Distribution {
- $query = $this->createQuery();
- $query->filterByCycleNumber($cycleNumber);
- $query->filterByYear($year);
- $query->filterBySection($section);
-
- return $query->findOne();
- }
- }
|