|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Stu\Module\Config\Model; |
|
4
|
|
|
|
|
5
|
|
|
use Noodlehaus\ConfigInterface; |
|
6
|
|
|
use Stu\Module\Config\StuConfigSettingEnum; |
|
7
|
|
|
|
|
8
|
|
|
class SettingsFactory implements SettingsFactoryInterface |
|
9
|
|
|
{ |
|
10
|
4 |
|
public function __construct(private ConfigInterface $config) |
|
11
|
|
|
{ |
|
12
|
4 |
|
} |
|
13
|
4 |
|
public function createSettings( |
|
14
|
|
|
StuConfigSettingEnum $type, |
|
15
|
|
|
?SettingsInterface $parent, |
|
16
|
|
|
SettingsCacheInterface $settingsCache |
|
17
|
|
|
): SettingsInterface { |
|
18
|
|
|
return match ($type) { |
|
19
|
4 |
|
StuConfigSettingEnum::ADMIN => new AdminSettings( |
|
20
|
4 |
|
$parent, |
|
21
|
4 |
|
$this->createSettingsCore($type, $parent), |
|
22
|
4 |
|
$settingsCache |
|
23
|
4 |
|
), |
|
24
|
4 |
|
StuConfigSettingEnum::CACHE => new CacheSettings( |
|
25
|
4 |
|
$parent, |
|
26
|
4 |
|
$this->createSettingsCore($type, $parent), |
|
27
|
4 |
|
$settingsCache |
|
28
|
4 |
|
), |
|
29
|
4 |
|
StuConfigSettingEnum::COLONY => new ColonySettings( |
|
30
|
4 |
|
$parent, |
|
31
|
4 |
|
$this->createSettingsCore($type, $parent), |
|
32
|
4 |
|
$settingsCache |
|
33
|
4 |
|
), |
|
34
|
4 |
|
StuConfigSettingEnum::DB => new DbSettings( |
|
35
|
4 |
|
$parent, |
|
36
|
4 |
|
$this->createSettingsCore($type, $parent), |
|
37
|
4 |
|
$settingsCache |
|
38
|
4 |
|
), |
|
39
|
4 |
|
StuConfigSettingEnum::DEBUG => new DebugSettings( |
|
40
|
4 |
|
$parent, |
|
41
|
4 |
|
$this->createSettingsCore($type, $parent), |
|
42
|
4 |
|
$settingsCache |
|
43
|
4 |
|
), |
|
44
|
4 |
|
StuConfigSettingEnum::GAME => new GameSettings( |
|
45
|
4 |
|
$parent, |
|
46
|
4 |
|
$this->createSettingsCore($type, $parent), |
|
47
|
4 |
|
$settingsCache |
|
48
|
4 |
|
), |
|
49
|
|
|
StuConfigSettingEnum::MAP => new MapSettings( |
|
50
|
|
|
$parent, |
|
51
|
|
|
$this->createSettingsCore($type, $parent), |
|
52
|
|
|
$settingsCache |
|
53
|
|
|
), |
|
54
|
|
|
StuConfigSettingEnum::RESET => new ResetSettings( |
|
55
|
|
|
$parent, |
|
56
|
|
|
$this->createSettingsCore($type, $parent), |
|
57
|
|
|
$settingsCache |
|
58
|
|
|
), |
|
59
|
4 |
|
StuConfigSettingEnum::SQL_LOGGING => new SqlLoggingSettings( |
|
60
|
4 |
|
$parent, |
|
61
|
4 |
|
$this->createSettingsCore($type, $parent), |
|
62
|
4 |
|
$settingsCache |
|
63
|
4 |
|
) |
|
64
|
|
|
}; |
|
65
|
|
|
} |
|
66
|
|
|
|
|
67
|
4 |
|
private function createSettingsCore(StuConfigSettingEnum $type, ?SettingsInterface $parent): SettingsCoreInterface |
|
68
|
|
|
{ |
|
69
|
4 |
|
return new SettingsCore( |
|
70
|
4 |
|
$parent, |
|
71
|
4 |
|
$type->getConfigPath(), |
|
72
|
4 |
|
$this->config |
|
73
|
4 |
|
); |
|
74
|
|
|
} |
|
75
|
|
|
} |
|
76
|
|
|
|