Path = $CONFIG->root() . "/Helper"; if(is_dir($this->Path)){ foreach(scandir($this->Path) as $helper){ if (preg_match('/(.+)Helper\.php$/i', $helper, $matches)) { require_once $this->Path . "/" . $helper; $baseName = $matches[1]; $className = $baseName . 'Helper'; if (class_exists($className)) { $this->Helpers[$baseName] = new $className(); } } } } // Charger les Helpers des plugins $this->Path = $CONFIG->root() . "/lib/plugins"; if(is_dir($this->Path)){ foreach(scandir($this->Path) as $plugin){ // Ne charger que s’il n’existe pas déjà un helper avec ce nom if(!isset($this->Helpers[ucfirst($plugin)])){ $path = $this->Path . "/" . $plugin . "/Helper.php"; if(is_file($path)){ $baseName = ucfirst($plugin); $className = $baseName . 'Helper'; // Tenter de charger la classe si elle existe if (class_exists($className)) { $this->Helpers[$baseName] = new $className(); } } } } } } // Méthodes magiques pour getters/setters public function __get($name) { return $this->Helpers[$name] ?? null; } public function __set($name, $value) { $this->Helpers[$name] = $value; } }