/** Datei: plugins/rest/library/ARUNOX/Plugins/REST/Notifications/Type.php **/ * @copyright 2025 ARUNOX * @version 1.0.0 * @since 1.0.0 File is created */ namespace ARUNOX\Plugins\REST\Notifications; /* ### ENUMS ######################################################## # */ enum Type : string { case Default = "default"; case Info = "info"; case Danger = "danger"; case Success = "success"; case Warning = "warning"; /* ### MAGIC FUNCTIONS ########################################## # */ } /** Datei: plugins/rest/library/ARUNOX/Plugins/REST/Notifications/Icon.php **/ * @copyright 2025 ARUNOX * @version 1.0.0 * @since 1.0.0 File is created */ namespace ARUNOX\Plugins\REST\Notifications; /* ### ENUMS ######################################################## # */ enum Icon : string { case Default = "bi bi-bell-fill"; case Info = "bi bi-info-lg"; case Danger = "bi bi-x-lg"; case Success = "bi bi-check-lg"; case Warning = "bi bi-exclamation-lg"; /* ### MAGIC FUNCTIONS ########################################## # */ } /** Datei: plugins/rest/library/ARUNOX/Plugins/REST/Notifications/Notification.php **/ * @copyright 2025 ARUNOX * @version 1.0.0 * @since 1.0.0 File is created */ namespace ARUNOX\Plugins\REST\Notifications; use ARUNOX\Plugins\REST\Generator\Config; use ARUNOX\Plugins\REST\Generator\Base\BaseGenerator; class Notification extends BaseGenerator { /* ### VARIABLES ################################################ # */ protected static ?string $PRIMARYKEY = "message"; protected ?string $GENERATOR = "notification"; protected array $ALLOWED_CONFIG = [ "type" => [ Config\Type::String, Type::class ], "message" => Config\Type::String, "title" => Config\Type::String, "duration" => Config\Type::Int, "icon" => [ Config\Type::String, Icon::class ], ]; /* ### PUBLIC STATIC FUNCTIONS ################################## # */ /* ### PUBLIC FUNCTIONS ######################################### # */ public function setIcon( ?string $icon = NULL ) { if( !$icon ) { $type = $this->config["type"]; if( $type && $icon = Icon::{$type->name} ) { return $this->set( "icon", $icon ); } } return $this->set( "icon", $icon ); } /* ### PUBLIC FUNCTIONS ######################################### # */ /* ### MAGIC FUNCTIONS ########################################## # */ } /** Datei: plugins/rest/library/ARUNOX/Plugins/REST/Notifications/Notifications.php **/ * @copyright 2025 ARUNOX * @version 1.0.0 * @since 1.0.0 File is created */ namespace ARUNOX\Plugins\REST; use ARUNOX\Plugins\REST\Notifications\Type; use ARUNOX\Plugins\REST\Notifications\Notification; use ARUNOX\Plugins\REST\Generator\Base\BaseWrapper; use ARUNOX\Plugins\REST\Generator\Base\BaseGenerator; class Notifications extends BaseWrapper { /* ### VARIABLES ################################################ # */ protected static string $TYPE = "wrapper"; protected ?string $HISTORY = NULL; protected static ?BaseGenerator $GENERATED = NULL; protected ?string $GENERATOR = "notifications"; protected array $ALLOWED_CONTENT = []; protected array $ALLOWED_CONFIG = []; /* ### PUBLIC FUNCTIONS ######################################### # */ /* ### PUBLIC STATIC FUNCTIONS ################################## # */ public static function create( ...$args ) : ?BaseGenerator { $type = array_shift( $args ); if( !$type = Type::tryFrom( strtolower( $type ) ) ) { $type = Type::Default; } if( ! static::$GENERATED ) { static::$GENERATED = parent::create(); } $notify = Generator::create( Notification::class ); static::$GENERATED->addContent( $notify ); $notify->setType( $type ); $notify->setIcon( $args[1] ?? NULL ); $notify->setDuration( $args[2] ?? NULL ); $notify->setTitle( $args[3] ?? NULL ); $notify->setParentNode( static::$GENERATED ); if( isset( $args[0] ) ) $notify->setMessage( $args[0] ); return $notify; } /* ### PRIVATE FUNCTIONS ######################################## # */ /* ### MAGIC FUNCTIONS ########################################## # */ public static function __callStatic( string $name, $args ) { return static::create( $name, ...$args ); } }