Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

42 rindas
1.1KB

  1. <?php
  2. namespace domain\Product\ProductAccessory;
  3. use domain\_\AbstractRepository;
  4. use domain\Product\Accessory\Accessory;
  5. use domain\Product\Product\Product;
  6. class ProductAccessoryRepository extends AbstractRepository
  7. {
  8. protected ProductAccessoryRepositoryQuery $query;
  9. public function loadDependencies(): void
  10. {
  11. $this->loadQuery(ProductAccessoryRepositoryQuery::class);
  12. }
  13. public function getDefaultOptionsSearch(): array
  14. {
  15. return [
  16. self::WITH => [],
  17. self::JOIN_WITH => ['accessoryRelation'],
  18. self::ORDER_BY => 'accessory.name ASC',
  19. self::ATTRIBUTE_ID_PRODUCER => ''
  20. ];
  21. }
  22. public function findOneProductAccessory(Product $product, Accessory $accessory): ?ProductAccessory
  23. {
  24. return $this->createDefaultQuery()
  25. ->filterByProduct($product)
  26. ->filterByAccessory($accessory)
  27. ->findOne();
  28. }
  29. public function findProductAccessoriesByAccessory(Accessory $accessory): array
  30. {
  31. return $this->createDefaultQuery()
  32. ->filterByAccessory($accessory)
  33. ->find();
  34. }
  35. }