You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

55 lines
1.4KB

  1. <?php
  2. namespace Lc\CaracoleBundle\Repository\Distribution;
  3. use App\Entity\Distribution\Distribution;
  4. use Lc\CaracoleBundle\Model\Section\SectionInterface;
  5. use Lc\CaracoleBundle\Repository\SectionStoreTrait;
  6. use Lc\SovBundle\Repository\AbstractStore;
  7. use Lc\SovBundle\Repository\RepositoryQueryInterface;
  8. class DistributionStore extends AbstractStore
  9. {
  10. use SectionStoreTrait;
  11. protected DistributionRepositoryQuery $query;
  12. public function __construct(DistributionRepositoryQuery $query)
  13. {
  14. $this->query = $query;
  15. }
  16. public function orderByDefault(RepositoryQueryInterface $query): RepositoryQueryInterface
  17. {
  18. $query->orderBy('id');
  19. return $query;
  20. }
  21. public function filtersDefault(RepositoryQueryInterface $query): RepositoryQueryInterface
  22. {
  23. $query->filterBySection($this->section);
  24. return $query;
  25. }
  26. public function relationsDefault(RepositoryQueryInterface $query): RepositoryQueryInterface
  27. {
  28. return $query;
  29. }
  30. public function getOneByCycleNumberYearAndSection(
  31. int $cycleNumber,
  32. int $year,
  33. string $cycleType,
  34. SectionInterface $section
  35. ): ?Distribution {
  36. $query = $this->createQuery();
  37. $query->filterByCycleNumber($cycleNumber);
  38. $query->filterByYear($year);
  39. $query->filterByCycleType($cycleType);
  40. $query->filterBySection($section);
  41. return $query->findOne();
  42. }
  43. }