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