put Api-Commands into namespaces

Signed-off-by: Michael Kaufmann <d00p@froxlor.org>
This commit is contained in:
Michael Kaufmann
2018-12-18 09:46:36 +01:00
parent c7e5df95e7
commit 4c27efa4ae
30 changed files with 831 additions and 667 deletions

View File

@@ -1,8 +1,8 @@
<?php
require __DIR__ . '/lib/classes/api/api_includes.inc.php';
require __DIR__ . '/vendor/autoload.php';
// check whether API interface is enabled after all
if (Settings::Get('api.enabled') != 1) {
if (\Froxlor\Settings::Get('api.enabled') != 1) {
// not enabled
header("Status: 404 Not found", 404);
header($_SERVER["SERVER_PROTOCOL"] . " 404 Not found", 404);
@@ -30,9 +30,9 @@ if (is_null($decoded_request)) {
// validate content
try {
$request = FroxlorRPC::validateRequest($decoded_request);
$request = \Froxlor\Api\FroxlorRPC::validateRequest($decoded_request);
// now actually do it
$cls = $request['command']['class'];
$cls = "\Froxlor\Api\Commands\\" . $request['command']['class'];
$method = $request['command']['method'];
$apiObj = new $cls($decoded_request['header'], $request['params']);
// call the method with the params if any