|
12345678910111213141516171819202122232425262728293031323334353637 |
- <?php
-
- namespace domain\Setting;
-
- use domain\_\AbstractManager;
-
- class AdminSettingBag extends AbstractManager
- {
- protected SettingRepository $settingRepository;
- protected SettingBuilder $settingBuilder;
-
- public function loadDependencies(): void
- {
- $this->settingRepository = $this->loadService(SettingRepository::class);
- $this->settingBuilder = $this->loadService(SettingBuilder::class);
- }
-
- public function get(string $name)
- {
- $setting = $this->settingRepository->findOneAdminSettingByName($name);
-
- if($setting) {
- return $setting->getValue();
- }
-
- return null;
- }
-
- public function set(string $name, $value)
- {
- $setting = $this->settingBuilder->createSetting($name);
-
- if($setting) {
- $this->settingBuilder->updateValue($setting, $value);
- }
- }
- }
|