mirror of
https://github.com/fenom-template/fenom.git
synced 2023-08-10 21:13:07 +03:00
Add autoloader
This commit is contained in:
@@ -964,4 +964,22 @@ class Fenom
|
||||
}
|
||||
return $mask;
|
||||
}
|
||||
|
||||
/**
|
||||
* Register PSR-0 autoload for Fenom
|
||||
* @param string $dir custom directory for autoloading, if NULL — autoload itself
|
||||
* @return bool
|
||||
*/
|
||||
public static function registerAutoload($dir = null)
|
||||
{
|
||||
if(!$dir) {
|
||||
$dir = __DIR__;
|
||||
}
|
||||
return spl_autoload_register(function($classname) use ($dir) {
|
||||
$file = $dir.DIRECTORY_SEPARATOR.str_replace('\\', DIRECTORY_SEPARATOR, $classname).'.php';
|
||||
if(is_file($file)) {
|
||||
require_once $file;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user