/** Datei: library/ARUNOX/Core/Plugins/Plugins.php **/ $config ) { // static::checkDependencies( $plugin, $config->dependencies ); } } public static function checkDependencies( string $plugin, array $dependencies ) : bool { foreach( $dependencies as $dependency ) { if( !( static::$allPlugins[ $dependency ]->active ?? FALSE ) ) { throw new \Exception("Missing dependency: {$dependency} for plugin {$plugin}"); } } return TRUE; } public static function get( string $plugin, bool $force = FALSE ) : ?Entity { if( empty( static::$allPlugins ) || $force ) self::loadAll( $force ); return static::$allPlugins[ $plugin ] ?? NULL; } public static function getAll( bool $force = FALSE ) : array { if( empty( static::$allPlugins ) || $force ) self::loadAll( $force ); return static::$allPlugins; } public static function getActive( bool $force = FALSE ) : array { static::getAll( $force ); return array_filter( static::$allPlugins, function( $plugin ) { return !$plugin->ignore && $plugin->active; } ); } public static function getPreload( bool $force = FALSE ) : array { static::getAll( $force ); return array_filter( static::$allPlugins, function( $plugin ) { return !$plugin->ignore && $plugin->preload; } ); } } /** Datei: library/ARUNOX/Core/Plugins/Entity.php **/ active = TRUE; } public function deactivate() { $this->active = FALSE; } public function setStatus( int|bool $status ) { if( $status ) $this->activate(); else $this->deactivate(); } public function checkDependencies() : bool { return Plugins::checkDependencies( $this->name, $this->dependencies ); } /* ### PROTECTED FUNCTIONS ###################################### # */ protected function load( $filename ) { $phpfile = new PHP( $filename ); $comment = $phpfile->get( T_DOC_COMMENT ); $data = (array)$comment->data; return (object)$data; } /* ### MAGIC FUNCTIONS ########################################## # */ public function __construct( $filename ) { $header = $this->load( $filename ); foreach( $header as $name => $value ) { $this->{$name} = $value; } $this->path = dirname( $filename ); $this->id = basename( $this->path ); $this->label = $this->name; $this->name = strtolower( $this->name ?? "" ); $this->plugin = $this->name; $this->ignore = isset( $this->ignore ); $this->active = filter_var( $this->active, FILTER_VALIDATE_BOOLEAN ); $this->preload = filter_var( $this->preload, FILTER_VALIDATE_BOOLEAN ); $this->dependencies = array_filter( preg_split( "/,\s/", $this->dependencies ?? "" ) ); } }