Nie możesz wybrać więcej, niż 25 tematów Tematy muszą się zaczynać od litery lub cyfry, mogą zawierać myślniki ('-') i mogą mieć do 35 znaków.

50 lines
1.2KB

  1. <?php
  2. namespace domain\Setting;
  3. use domain\_\AbstractRepository;
  4. class SettingRepository extends AbstractRepository
  5. {
  6. protected SettingRepositoryQuery $query;
  7. public function loadDependencies(): void
  8. {
  9. $this->loadQuery(SettingRepositoryQuery::class);
  10. }
  11. public function getDefaultOptionsSearch(): array
  12. {
  13. return [
  14. self::WITH => ['producer'],
  15. self::JOIN_WITH => [],
  16. self::ORDER_BY => '',
  17. self::ATTRIBUTE_ID_PRODUCER => 'setting.id_producer'
  18. ];
  19. }
  20. public function findOneSettingByName(string $name)
  21. {
  22. if($this->isOutOfProducerContext()) {
  23. return $this->findOneAdminSettingByName($name);
  24. }
  25. else {
  26. return $this->findOneProducerSettingByName($name);
  27. }
  28. }
  29. public function findOneAdminSettingByName(string $name)
  30. {
  31. return $this->createQuery()
  32. ->filterProducerIsNull()
  33. ->filterByName($name)
  34. ->findOne();
  35. }
  36. public function findOneProducerSettingByName(string $name)
  37. {
  38. return $this->createDefaultQuery()
  39. ->filterByName($name)
  40. ->findOne();
  41. }
  42. }