Conditions | 4 |
Paths | 4 |
Total Lines | 27 |
Code Lines | 17 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | <?php |
||
14 | public function updateConfig() |
||
15 | { |
||
16 | $this->onlyAdmin(); |
||
17 | if (!$this->container->getRequest()->isPost()) { |
||
18 | throw new JsonException('Call is not post'); |
||
19 | } |
||
20 | //prepating our return results |
||
21 | $result = array(); |
||
22 | $result['successId'] = []; |
||
23 | $result['errorId'] = []; |
||
24 | $result['success'] = true; |
||
25 | $configUpdateJson = $this->container->getRequest()->getData('config-update'); |
||
26 | $configUpdate = json_decode($configUpdateJson); |
||
27 | |||
28 | $configModel = new ConfigModel($this->container); |
||
29 | |||
30 | foreach ($configUpdate as $update) { |
||
31 | |||
32 | if (!$configModel->updateConfig($update->dbId, $update->value)) { |
||
33 | $result['success'] = false; |
||
34 | $result['errorId'][] = $update->id; |
||
35 | } else { |
||
36 | $result['successId'][] = $update->id; |
||
37 | } |
||
38 | } |
||
39 | |||
40 | echo json_encode($result); |
||
41 | } |
||
42 | } |