devsuite/cds/actions/Crispage/DevSuite/ConsoleAction.php

47 lines
1.2 KiB
PHP
Raw Permalink Normal View History

2024-05-27 00:44:14 -04:00
<?php
namespace Crispage\DevSuite;
defined("ROOT") or die();
use \Crispage\Auth\CorePermissions;
class ConsoleAction extends \Crispage\Framework\Action {
public static function getExtensionInfo(): array {
return [
"id" => "crispage.devsuite.actions.console",
"version" => VERSION,
"package" => "crispage.devsuite"
];
}
public function __construct(\Crispage $app, array $data) {
parent::__construct($app, $data);
}
public function run(): void {
$this->app->page->data["title"] = $this->app->i18n->translate("{%CDS_CONSOLE}");
if (!$this->app->auth->userHasPermission(
CorePermissions::MANAGE_EXTENSIONS
)) {
$this->app->page->setPersistentMessage(
"unauthorized", "Unauthorized", "danger"
);
$this->app->page->actionFinished();
}
$script = strval($this->app->request->params["script"] ?? "");
if (strlen($script))
$output = $this->app->cds->runScript($script);
$com_main = $this->app->page->createComponent(
"\\Crispage\\DevSuite\\ConsoleComponent",
["script" => $script, "output" => $output ?? ""]
);
$this->app->page->setMainComponent($com_main);
$this->app->page->actionFinished();
}
}
?>