<?php
namespace SHServ\Controllers;
use \SHServ\Middleware\ControlScripts;
class ScriptsRESTAPIController extends \SHServ\Middleware\Controller {
public function run_action_script($alias, $params) {
$result = ControlScripts::run_action_script($alias, $params);
if(!$result) {
return $this -> utils() -> response_error("action_script_not_found");
}
return $this -> utils() -> response_success([
"return" => $result
]);
}
public function actions_scripts_list() {
$scripts = ControlScripts::get_actions_scripts();
$data = [];
foreach($scripts as $alias => $script_data) {
$data[] = [
"alias" => $alias,
"name" => $script_data["attributes"]["name"],
"description" => $script_data["attributes"]["description"],
"filename" => $script_data["attributes"]["filename"],
"path" => $script_data["attributes"]["path"],
"created_by" => $script_data["attributes"]["author"],
];
}
return $this -> utils() -> response_success([
"scripts" => $data,
"total" => count($data)
]);
}
}