Total Complexity | 4 |
Total Lines | 54 |
Duplicated Lines | 0 % |
Changes | 0 |
1 | <?php |
||
9 | class Tag extends AjaxController |
||
10 | { |
||
11 | |||
12 | |||
13 | /** |
||
14 | * Update the tag via ajax |
||
15 | * @throws \Core\JsonException |
||
16 | */ |
||
17 | public function update() |
||
18 | { |
||
19 | //security checks |
||
20 | $this->onlyAdmin(); |
||
21 | $this->onlyPost(); |
||
22 | |||
23 | //preparing our return results |
||
24 | $result = array(); |
||
25 | $tagUpdateJson = ($this->request->getData('tag-update')); |
||
26 | $tagUpdate = json_decode($tagUpdateJson); |
||
27 | |||
28 | //Converting our array of objects to simple array |
||
29 | $send = array(); |
||
30 | foreach ($tagUpdate as $item) { |
||
31 | $send[$item->name] = $item->value; |
||
32 | } |
||
33 | |||
34 | $tagModel = new TagModel($this->container); |
||
35 | $result['success'] = $tagModel->update($send["idtags"], $send["tag_name"]); |
||
36 | echo json_encode($result); |
||
37 | } |
||
38 | |||
39 | /** |
||
40 | * Delete a tag via Ajax |
||
41 | * @throws \Core\JsonException |
||
42 | */ |
||
43 | public function delete() |
||
63 | } |
||
64 | } |