選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

AdminSettingBag.php 876B

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