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.

39 lines
971B

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