|
- <?php
-
- namespace common\logic\Setting;
-
- use common\logic\AbstractManager;
- use common\logic\Setting\SettingBuilder;
- use common\logic\Setting\SettingRepository;
-
- 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);
- }
- }
- }
|