/** Datei: plugins/dev/library/ARUNOX/Plugins/Dev/Plugins/API/v1/Routes.php **/ * @copyright 2025 ARUNOX * @version 1.1.0 * * @since 1.0.0 File is created */ namespace ARUNOX\Plugins\Dev\Plugins\API\v1; use ARUNOX\Core\Hooks; use ARUNOX\Core\Router; use ARUNOX\Plugins\Users; class Routes { public static function register() : void { /* ### MAIN ROUTES ############################## # */ Router::addAll( Controller::class ); /* ### MENU ROUTES ############################## # */ Hooks::add('router::get->api.v1.rest.routes', function( $routes ) { if( !Users\Model::isSuperadmin() ) return $routes; $routes[] = [ "path" => "/dev/plugins", "label" => "Plugins", "icon" => "bi bi-puzzle", "menu" => "development", ]; return $routes; }); } } /** Datei: plugins/dev/library/ARUNOX/Plugins/Dev/Plugins/API/v1/Controller.php **/ * @copyright 2025 ARUNOX * @version 1.1.0 * * @since 1.0.0 File is created */ namespace ARUNOX\Plugins\Dev\Plugins\API\v1; use ARUNOX\HTTP; use ARUNOX\Core\Hooks; use ARUNOX\Plugins\REST; use ARUNOX\Plugins\Dev; use ARUNOX\API\BaseController; use ARUNOX\Database\Attribute; use ARUNOX\Plugins\Systems\Ignore; class Controller extends BaseController { /* ### VARIABLES ################################################ # */ protected static array $NOTIFY = [ "notfound" => "Plugin nicht gefunden", "created" => "Plugin Version wurde erfolgreich erstellt", "updated" => "Plugin Version wurde erfolgreich aktualisiert", "notcreated" => "Plugin Version konnte nicht erstellt werden", "notupdated" => "Plugin Version konnte nicht aktualisiert werden", ]; /* ### PUBLIC GET FUNCTIONS ##################################### # */ /** * @api * @method GET * * @route.path /dev/plugins * @route.description Listet alle Agents */ public static function getAll() : array { return Dev\Plugins\Model::getAll(); } /* ### PUBLIC SAVE FUNCTIONS #################################### # */ public function versionCreate( string $id, array $data ) { if( $result = Dev\Plugins\Model::get( $id ) ) { if( $result->versionCreate( $data["version"] ) ) { REST\Response::addNotify( "success", static::$NOTIFY["created"] ); REST\Response::closeModals(); REST\Response::addUpdater( [ "data/table/row", $id ], $result ); } else REST\Response::addNotify( "danger", static::$NOTIFY["notcreated"] ); } else REST\Response::addNotify( "danger", static::$NOTIFY["notfound"] ); return REST\Response::jsonResponse(); } /* ### PUBLIC VALIDATE FUNCTIONS ################################ # */ /* ### PUBLIC REST FUNCTIONS #################################### # */ /* ### PUBLIC REST RESPONSE FUNCTIONS ########################### # */ /* ### PUBLIC REST CONFIG FUNCTIONS ############################# # */ /** * @internal rest * @method GET * * @route.path /dev/plugins * @route.description REST-Konfiguration für Agenten-Tabelle */ public static function restConfigOverview() { return REST\Response::addWrapper( "overview", "Plugins" ) ->get() ->setApi( "/dev/plugins" ) ->setAction( "/dev/plugins/{hashid}" ) ->setOrder( "plugin", "asc" ) ->setSearch( TRUE ) ->addButton(...Hooks::filter( "rest.generator::button.name->create", [], "dev/plugins" )) ->addColumn(...Hooks::filter( "rest.generator::column.type->text", [], "label", TRUE, TRUE, TRUE, "dev/plugins" )) ->addColumn(...Hooks::filter( "rest.generator::column.type->icon", [ "icon" => "bi-eye", "options" => Dev\Plugins\Ignore::getAll(), ], "ignore", [], "dev/plugins" )) ->addColumn(...Hooks::filter( "rest.generator::column.type->icon", [ "icon" => "bi-lightning-charge-fill", "options" => Dev\Plugins\Preload::getAll(), ], "preload", [], "dev/plugins" )) ->addColumn(...Hooks::filter( "rest.generator::column.type->text", [], "version", TRUE, TRUE, TRUE, "dev/plugins" )) ->get() ->addButton(...Hooks::filter( "rest.generator::action.name->edit", [ "label" => "Versionieren", "icon" => "bi bi-tag", "color" => REST\Generator\Config\Color::Secondary, "action" => "/dev/plugins/{hashid}/version", ], "dev/plugins" )) ->parent() ->addColumn(...Hooks::filter( "rest.generator::column.type->text", [], "author", TRUE, TRUE, TRUE, "dev/plugins" )) ->addColumn(...Hooks::filter( "rest.generator::column.type->text", [], "description", TRUE, TRUE, TRUE, "dev/plugins" )) ->addColumn(...Hooks::filter( "rest.generator::column.type->actions", [], [], FALSE, "dev/plugins" ))->get() ->addButton(...Hooks::filter( "rest.generator::action.name->edit", [], "dev/plugins", "hashid" )) ->addButton(...Hooks::filter( "rest.generator::action.name->delete", [], "dev/plugins", "hashid" )) ; } public static function restConfigVersion( string $id ) { $data = Dev\Plugins\Model::get( $id ); return REST\Response::addModal( "details", "Versionieren" ) ->setSize( REST\Wrapper\Modal\Size::sm ) ->setData( $data ) ->get() ->setAction( "/dev/plugins/{id}/version", "PUT" ) ->addButton(...Hooks::filter( "rest.generator::button.type->submit", [], "Erstellen", "dev/plugins" )) ->addField(...Hooks::filter( "rest.generator::control.type->radio", [ "options" => $data->getVersionsAsOptions(), "value" => $data->getPatchVersion(), ], "version", TRUE, FALSE, "dev/plugins" )) ->top(); } /* ### PUBLIC REST EXTENSION FUNCTIONS ########################## # */ }