diff --git a/system/autoload.php b/system/autoload.php index df6bbab..41cdb1f 100644 --- a/system/autoload.php +++ b/system/autoload.php @@ -5,6 +5,7 @@ class autoload { private static $files = array(); // array(class, namespace, file) private static $folders = array(); // array(namespace, folder) + private static $func = array(); // array(namespace, func) private static function getClassFromFile($file){ $path_info = \pathinfo($file); @@ -36,6 +37,11 @@ class autoload { require_once $folder[1].'/'.$class.'.php'; return true;} } + + foreach(self::$func as $func){ + if(strtolower($func[0]) == strtolower($namespace) && call_user_func($func[1],$class)){ + return true;} + } return false; } @@ -54,6 +60,12 @@ class autoload { self::$folders[] = array($namespace, $folder); } + public static function registerFunc($func, $namespace = ''){ + /*if(!_exists($func)){ + throw new \SYSTEM\LOG\ERROR('Function not found on registerFunc for Autoload: '.$func);}*/ + self::$func[] = array($namespace, $func); + } + public static function register_autoload(){ spl_autoload_register('\SYSTEM\autoload::autoload');}