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.

49 line
1.4KB

  1. <?php
  2. namespace domain\Distribution\ProductDistribution;
  3. use domain\Distribution\Distribution\Distribution;
  4. use domain\Product\Product\Product;
  5. use domain\_\AbstractRepository;
  6. class ProductDistributionRepository extends AbstractRepository
  7. {
  8. protected ProductDistributionRepositoryQuery $query;
  9. public function loadDependencies(): void
  10. {
  11. $this->loadQuery(ProductDistributionRepositoryQuery::class);
  12. }
  13. public function getDefaultOptionsSearch(): array
  14. {
  15. return [
  16. self::WITH => ['product','distribution'],
  17. self::JOIN_WITH => [],
  18. self::ORDER_BY => '',
  19. self::ATTRIBUTE_ID_PRODUCER => ''
  20. ] ;
  21. }
  22. public function findOneProductDistribution(Distribution $distribution, Product $product): ?ProductDistribution
  23. {
  24. return $this->createDefaultQuery()
  25. ->filterByDistribution($distribution)
  26. ->filterByProduct($product)
  27. ->findOne();
  28. }
  29. public function findProductDistributionsByDistribution(Distribution $distribution): array
  30. {
  31. return $this->createDefaultQuery()
  32. ->filterByDistribution($distribution)
  33. ->find();
  34. }
  35. public function countProductDistributionsByDistribution(Distribution $distribution): int
  36. {
  37. return $this->createDefaultQuery()
  38. ->filterByDistribution($distribution)
  39. ->count();
  40. }
  41. }