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.

45 lines
1.3KB

  1. <?php
  2. namespace domain\Subscription\ProductSubscription;
  3. use domain\Product\Rotating\Rotating;
  4. use domain\Subscription\Subscription\Subscription;
  5. use domain\_\AbstractRepository;
  6. class ProductSubscriptionRepository extends AbstractRepository
  7. {
  8. protected ProductSubscriptionRepositoryQuery $query;
  9. public function loadDependencies(): void
  10. {
  11. $this->loadQuery(ProductSubscriptionRepositoryQuery::class);
  12. }
  13. /**
  14. * Retourne les options de base nécessaires à la fonction de recherche.
  15. */
  16. public function getDefaultOptionsSearch(): array
  17. {
  18. return [
  19. self::WITH => ['productRelation'],
  20. self::JOIN_WITH => [],
  21. self::ORDER_BY => '',
  22. self::ATTRIBUTE_ID_PRODUCER => ''
  23. ];
  24. }
  25. public function findProductSubscriptionsBySubscription(Subscription $subscription): array
  26. {
  27. return $this->createDefaultQuery()
  28. ->filterBySubscription($subscription)
  29. ->find();
  30. }
  31. public function findOneProductSubscriptionBySubscriptionAndRotating(Subscription $subscription, Rotating $rotating): ?ProductSubscription
  32. {
  33. return $this->createDefaultQuery()
  34. ->filterBySubscription($subscription)
  35. ->filterByRotating($rotating)
  36. ->findOne();
  37. }
  38. }