autoload register own autoload(required for libraries)
This commit is contained in:
parent
711ea543d4
commit
f424846436
@ -5,6 +5,7 @@ class autoload {
|
|||||||
|
|
||||||
private static $files = array(); // array(class, namespace, file)
|
private static $files = array(); // array(class, namespace, file)
|
||||||
private static $folders = array(); // array(namespace, folder)
|
private static $folders = array(); // array(namespace, folder)
|
||||||
|
private static $func = array(); // array(namespace, func)
|
||||||
|
|
||||||
private static function getClassFromFile($file){
|
private static function getClassFromFile($file){
|
||||||
$path_info = \pathinfo($file);
|
$path_info = \pathinfo($file);
|
||||||
@ -36,6 +37,11 @@ class autoload {
|
|||||||
require_once $folder[1].'/'.$class.'.php';
|
require_once $folder[1].'/'.$class.'.php';
|
||||||
return true;}
|
return true;}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
foreach(self::$func as $func){
|
||||||
|
if(strtolower($func[0]) == strtolower($namespace) && call_user_func($func[1],$class)){
|
||||||
|
return true;}
|
||||||
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -54,6 +60,12 @@ class autoload {
|
|||||||
self::$folders[] = array($namespace, $folder);
|
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(){
|
public static function register_autoload(){
|
||||||
spl_autoload_register('\SYSTEM\autoload::autoload');}
|
spl_autoload_register('\SYSTEM\autoload::autoload');}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user