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.

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  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. }