1 | <?php |
||
12 | class Settings |
||
13 | { |
||
14 | |||
15 | /** |
||
16 | * @var Gateway |
||
17 | */ |
||
18 | private $gateway; |
||
19 | |||
20 | /** |
||
21 | * @Inject("@User.Settings.Gateway") |
||
22 | * @param Gateway $gateway |
||
23 | */ |
||
24 | 4 | public function __construct(Gateway $gateway) |
|
25 | { |
||
26 | 4 | $this->gateway = $gateway; |
|
27 | 4 | } |
|
28 | |||
29 | /** |
||
30 | * @param int $userId |
||
31 | * @param string $setting |
||
32 | * @return string |
||
33 | */ |
||
34 | 2 | public function get(int $userId, string $setting) |
|
35 | { |
||
36 | 2 | $value = $this->gateway->get($userId, $setting); |
|
37 | |||
38 | 2 | if (empty($value) && $userId) { |
|
39 | 1 | $value = $this->get(0, $setting); |
|
40 | } |
||
41 | |||
42 | 2 | return $value; |
|
43 | } |
||
44 | |||
45 | /** |
||
46 | * @param int $userId |
||
47 | * @return string[] |
||
48 | */ |
||
49 | 1 | public function getAll(int $userId) : array |
|
59 | |||
60 | /** |
||
61 | * @param int $userId |
||
62 | * @param string $setting |
||
63 | * @param string $value |
||
64 | */ |
||
65 | 1 | public function set(int $userId, string $setting, $value) |
|
69 | } |
||
70 |