1 | <?php |
||
34 | class ConfigService { |
||
35 | |||
36 | const BOOKMARKS_TTL = 'bookmarks_ttl'; |
||
37 | |||
38 | private $defaults = [ |
||
39 | self::BOOKMARKS_TTL => '5' |
||
40 | ]; |
||
41 | |||
42 | |||
43 | /** @var IConfig */ |
||
44 | private $config; |
||
45 | |||
46 | /** @var string */ |
||
47 | private $userId; |
||
48 | |||
49 | /** @var MiscService */ |
||
50 | private $miscService; |
||
51 | |||
52 | /** |
||
53 | * ConfigService constructor. |
||
54 | * |
||
55 | * @param IConfig $config |
||
56 | * @param string $userId |
||
57 | * @param MiscService $miscService |
||
58 | */ |
||
59 | public function __construct(IConfig $config, $userId, MiscService $miscService) { |
||
64 | |||
65 | |||
66 | /** |
||
67 | * @return array |
||
68 | */ |
||
69 | public function getConfig() { |
||
79 | |||
80 | |||
81 | /** |
||
82 | * @param array $save |
||
83 | */ |
||
84 | public function setConfig($save) { |
||
93 | |||
94 | |||
95 | /** |
||
96 | * Get a value by key |
||
97 | * |
||
98 | * @param string $key |
||
99 | * |
||
100 | * @return string |
||
101 | */ |
||
102 | public function getAppValue($key) { |
||
103 | $defaultValue = null; |
||
104 | if (array_key_exists($key, $this->defaults)) { |
||
105 | $defaultValue = $this->defaults[$key]; |
||
106 | } |
||
107 | |||
108 | return $this->config->getAppValue(Application::APP_NAME, $key, $defaultValue); |
||
109 | } |
||
110 | |||
111 | /** |
||
112 | * Set a value by key |
||
113 | * |
||
114 | * @param string $key |
||
115 | * @param string $value |
||
116 | * |
||
117 | * @return void |
||
118 | */ |
||
119 | public function setAppValue($key, $value) { |
||
122 | |||
123 | /** |
||
124 | * remove a key |
||
125 | * |
||
126 | * @param string $key |
||
127 | * |
||
128 | * @return string |
||
129 | */ |
||
130 | public function deleteAppValue($key) { |
||
133 | |||
134 | |||
135 | /** |
||
136 | * return if option is enabled. |
||
137 | * |
||
138 | * @param $key |
||
139 | * |
||
140 | * @return bool |
||
141 | */ |
||
142 | public function optionIsSelected($key) { |
||
145 | |||
146 | |||
147 | /** |
||
148 | * return the cloud version. |
||
149 | * if $complete is true, return a string x.y.z |
||
150 | * |
||
151 | * @param boolean $complete |
||
152 | * |
||
153 | * @return string|integer |
||
154 | */ |
||
155 | public function getCloudVersion($complete = false) { |
||
164 | } |
||
165 |