|
@ -11,10 +11,27 @@ |
|
|
|
|
|
|
|
|
class Load |
|
|
class Load |
|
|
{ |
|
|
{ |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static protected $file; |
|
|
static protected $file; |
|
|
|
|
|
|
|
|
static protected $autoload; |
|
|
static protected $autoload; |
|
|
|
|
|
|
|
|
|
|
|
static protected $exclude = array('/.git', '/lib/core/tests', '/lib/core/.git'); |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
* Add exclude path for autoload. Should be called before setAutoloadFrom |
|
|
|
|
|
* @static |
|
|
|
|
|
* @param array $exclude list of relative path (from project root) |
|
|
|
|
|
* @return void |
|
|
|
|
|
*/ |
|
|
|
|
|
static public function setExclude($exclude = array()) |
|
|
|
|
|
{ |
|
|
|
|
|
if(!is_array($exclude)) { |
|
|
|
|
|
$exclude = array($exclude); |
|
|
|
|
|
} |
|
|
|
|
|
self::$exclude = array_merge(self::$exclude, $exclude); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
static public function setAutoloadFrom($file) |
|
|
static public function setAutoloadFrom($file) |
|
|
{ |
|
|
{ |
|
|
self::$file = $file; |
|
|
self::$file = $file; |
|
@ -23,7 +40,7 @@ class Load |
|
|
} |
|
|
} |
|
|
self::$autoload = require(self::$file); |
|
|
self::$autoload = require(self::$file); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static public function autoload($class) |
|
|
static public function autoload($class) |
|
|
{ |
|
|
{ |
|
|
if (isset(self::$autoload[$class])) { |
|
|
if (isset(self::$autoload[$class])) { |
|
@ -35,16 +52,16 @@ class Load |
|
|
self::buildAutoload(); |
|
|
self::buildAutoload(); |
|
|
} |
|
|
} |
|
|
if (isset(self::$autoload[$class])) { |
|
|
if (isset(self::$autoload[$class])) { |
|
|
require(PATH . self::$autoload[$class]); |
|
|
|
|
|
|
|
|
require(PATH . self::$autoload[$class]); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static public function getFilePath($class) |
|
|
static public function getFilePath($class) |
|
|
{ |
|
|
{ |
|
|
return self::$autoload[$class]; |
|
|
return self::$autoload[$class]; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static protected function buildAutoload() |
|
|
static protected function buildAutoload() |
|
|
{ |
|
|
{ |
|
|
ignore_user_abort(true); |
|
|
ignore_user_abort(true); |
|
@ -52,12 +69,11 @@ class Load |
|
|
if (!file_exists($dir) && !mkdir($dir)) { |
|
|
if (!file_exists($dir) && !mkdir($dir)) { |
|
|
trigger_error('Can\'t create directory: "' . $dir . '"', E_USER_ERROR); |
|
|
trigger_error('Can\'t create directory: "' . $dir . '"', E_USER_ERROR); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$scan = array(PATH . '/' . APP . '/src', PATH . '/lib'); |
|
|
$scan = array(PATH . '/' . APP . '/src', PATH . '/lib'); |
|
|
|
|
|
|
|
|
require_once(PATH . '/lib/core/util/AutoloadBuilder.php'); |
|
|
require_once(PATH . '/lib/core/util/AutoloadBuilder.php'); |
|
|
|
|
|
|
|
|
$builder = new AutoloadBuilder(self::$file, $scan); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$builder = new AutoloadBuilder(self::$file, $scan, self::$exclude); |
|
|
$builder->build(); |
|
|
$builder->build(); |
|
|
ignore_user_abort(false); |
|
|
ignore_user_abort(false); |
|
|
} |
|
|
} |