/** Datei: plugins/rest/library/ARUNOX/Plugins/REST/Generator/Helpers/ButtonHelpers.php **/ * @copyright 2025 ARUNOX * @version 1.0.0 * @since 1.0.0 File is created */ namespace ARUNOX\Plugins\REST\Generator\Helpers; use ARUNOX\Plugins\REST\Generator\Components\Button; trait ButtonHelpers { /* ### TRAIT INIT FUNCTIONS ##################################### # */ public function ButtonHelpersInit() { $this->addAllowedConfig( "buttons", [ "generator" => Button::class, "args" => [], ]); } /* ### PUBLIC FUNCTIONS ######################################### # */ public function setButtons( $args ) { return $this->addButtons( ...$args ); } public function addButton( ...$args ) { return $this->add( "buttons", ...$args ); } public function addButtons( ...$args ) { foreach( $args as $arg ) { $this->addButton( ...$arg ); } return $this; } } /** Datei: plugins/rest/library/ARUNOX/Plugins/REST/Generator/Helpers/ActionHelpers.php **/ * @copyright 2025 ARUNOX * @version 1.0.0 * @since 1.0.0 File is created */ namespace ARUNOX\Plugins\REST\Generator\Helpers; trait ActionHelpers { /* ### TRAIT INIT FUNCTIONS ##################################### # */ public function ActionHelpersInit() { $this->addAllowedConfig( "action", [ "generator" => NULL, "args" => [], ]); } /* ### PUBLIC FUNCTIONS ######################################### # */ public function setNamedAction( string $name = "action", null|bool|string|array $route = NULL, ?string $method = 'GET', null|array $query = [] ) : self { if( $route === FALSE ) return $this; if( is_array( $route ) ) { extract( array_replace([ "route" => NULL, "method" => "GET", ], $route )); } $this->config[ $name ] = []; // if( $api && !str_starts_with( $api, '/api/' ) ) { // throw new \Exception("❌ Ungültige API-URL für Formular: {$api}"); // } if( $route ) $this->config[ $name ]["route"] = $route; if( $method ) $this->config[ $name ]["method"] = $method; if( $query ) $this->config[ $name ]["query"] = $query; return $this; } public function getNamedAction( string $name = "action", ...$args ) { if( key_exists( $name, $this->config ) ) { $value = $this->config[ $name ]; foreach( $args as $arg ) { if( key_exists( $arg, $value ) ) { $value = $value[ $arg ]; } } return $value; } return NULL; } public function setAction( null|string|array $route = NULL, ?string $method = 'GET' ) : self { return $this->setNamedAction( "action", $route, $method ); } public function getAction( ...$args ) { return $this->getNamedAction( "action", ...$args ); } } /** Datei: plugins/rest/library/ARUNOX/Plugins/REST/Generator/Helpers/TextHelpers.php **/ * @copyright 2025 ARUNOX * @version 1.0.0 * @since 1.0.0 File is created */ namespace ARUNOX\Plugins\REST\Generator\Helpers; use ARUNOX\Plugins\REST\Generator\Config; use ARUNOX\Plugins\REST\Generator\Components\Headline; use ARUNOX\Plugins\REST\Generator\Components\Paragraph; trait TextHelpers { /* ### TRAIT INIT FUNCTIONS ##################################### # */ public function TextHelpersInit() { $this->addAllowedContent( "headline", [ "generator" => Headline::class, "args" => [ Config\Type::String ], ]); $this->addAllowedContent( "text", [ "generator" => Paragraph::class, "args" => [ Config\Type::String ], ]); } /* ### PUBLIC FUNCTIONS ######################################### # */ }