Path = $CONFIG->root() . "/Model"; if(is_dir($this->Path)){ foreach(scandir($this->Path) as $model){ if (preg_match('/(.+)Model\.php$/i', $model, $matches)) { require_once $this->Path . "/" . $model; $baseName = $matches[1]; $className = $baseName . 'Model'; if (class_exists($className)) { $this->Models[$baseName] = new $className(); } } } } // Charger les Models des plugins $this->Path = $CONFIG->root() . "/lib/plugins"; if(is_dir($this->Path)){ foreach(scandir($this->Path) as $plugin){ if(!isset($this->Models[ucfirst($plugin)])){ $path = $this->Path . "/" . $plugin . "/Model.php"; if(is_file($path)){ $baseName = ucfirst($plugin); $className = $baseName . 'Model'; if (class_exists($className)) { $this->Models[$baseName] = new $className(); } } } } } } public function __get($name) { return $this->Models[$name] ?? null; } public function __set($name, $value) { $this->Models[$name] = $value; } }