您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

50 行
1.2KB

  1. <?php
  2. namespace common\logic\Setting;
  3. use common\logic\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. }