1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace App\Controllers\Ajax; |
4
|
|
|
|
5
|
|
|
use App\Models\TagModel; |
6
|
|
|
use Core\AjaxController; |
7
|
|
|
|
8
|
|
|
class Tag extends AjaxController{ |
9
|
|
|
|
10
|
|
|
|
11
|
|
|
/** |
12
|
|
|
* Update the tag via ajax |
13
|
|
|
* @throws \Core\JsonException |
14
|
|
|
*/ |
15
|
|
|
public function update() |
16
|
|
|
{ |
17
|
|
|
//security checks |
18
|
|
|
$this->onlyAdmin(); |
19
|
|
|
if (!$this->request->isPost()) { |
20
|
|
|
throw new JsonException('Call is not post'); |
|
|
|
|
21
|
|
|
} |
22
|
|
|
|
23
|
|
|
//prepating 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() |
44
|
|
|
{ |
45
|
|
|
//security checks |
46
|
|
|
$this->onlyAdmin(); |
47
|
|
|
if (!$this->request->isPost()) { |
48
|
|
|
throw new JsonException('Call is not post'); |
49
|
|
|
} |
50
|
|
|
|
51
|
|
|
//prepating our return results |
52
|
|
|
$result = array(); |
53
|
|
|
$DeleteJson = ($this->request->getData('tag-delete')); |
54
|
|
|
$Delete = json_decode($DeleteJson); |
55
|
|
|
|
56
|
|
|
//Converting our array of objects to simple array |
57
|
|
|
$send = array(); |
58
|
|
|
foreach ($Delete as $item) { |
59
|
|
|
$send[$item->name] = $item->value; |
60
|
|
|
} |
61
|
|
|
|
62
|
|
|
$tagModel = new TagModel($this->container); |
63
|
|
|
$result['success'] = $tagModel->delete($send["idtags"]); |
64
|
|
|
echo json_encode($result); |
65
|
|
|
} |
66
|
|
|
} |
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"]
, you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths