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

37 行
876B

  1. <?php
  2. namespace domain\Setting;
  3. use domain\_\AbstractManager;
  4. class AdminSettingBag extends AbstractManager
  5. {
  6. protected SettingRepository $settingRepository;
  7. protected SettingBuilder $settingBuilder;
  8. public function loadDependencies(): void
  9. {
  10. $this->settingRepository = $this->loadService(SettingRepository::class);
  11. $this->settingBuilder = $this->loadService(SettingBuilder::class);
  12. }
  13. public function get(string $name)
  14. {
  15. $setting = $this->settingRepository->findOneAdminSettingByName($name);
  16. if($setting) {
  17. return $setting->getValue();
  18. }
  19. return null;
  20. }
  21. public function set(string $name, $value)
  22. {
  23. $setting = $this->settingBuilder->createSetting($name);
  24. if($setting) {
  25. $this->settingBuilder->updateValue($setting, $value);
  26. }
  27. }
  28. }