You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
64 lines
1.6 KiB
64 lines
1.6 KiB
<?php
|
|
/**
|
|
* @copyright NetMonsters <team@netmonsters.ru>
|
|
* @link http://netmonsters.ru
|
|
* @package Majestic
|
|
* @subpackage Load
|
|
* @since 2010-02-24
|
|
* @version SVN: $Id$
|
|
* @filesource $URL$
|
|
*/
|
|
|
|
class Load
|
|
{
|
|
|
|
static protected $file;
|
|
static protected $autoload;
|
|
|
|
static public function setAutoloadFrom($file)
|
|
{
|
|
self::$file = $file;
|
|
if (!file_exists(self::$file)) {
|
|
self::buildAutoload();
|
|
}
|
|
self::$autoload = require(self::$file);
|
|
}
|
|
|
|
static public function autoload($class)
|
|
{
|
|
if (isset(self::$autoload[$class])) {
|
|
require(PATH . self::$autoload[$class]);
|
|
return;
|
|
}
|
|
if (defined('DEBUG') && DEBUG == true) {
|
|
if (!isset(self::$autoload[$class])) {
|
|
self::buildAutoload();
|
|
}
|
|
if (isset(self::$autoload[$class])) {
|
|
require(PATH . self::$autoload[$class]);
|
|
}
|
|
}
|
|
}
|
|
|
|
static public function getFilePath($class)
|
|
{
|
|
return self::$autoload[$class];
|
|
}
|
|
|
|
static protected function buildAutoload()
|
|
{
|
|
ignore_user_abort(true);
|
|
$dir = dirname(self::$file);
|
|
if (!file_exists($dir) && !mkdir($dir)) {
|
|
trigger_error('Can\'t create directory: "' . $dir . '"', E_USER_ERROR);
|
|
}
|
|
|
|
$scan = array(PATH . '/' . APP . '/src', PATH . '/lib');
|
|
|
|
require_once(PATH . '/lib/core/util/AutoloadBuilder.php');
|
|
|
|
$builder = new AutoloadBuilder(self::$file, $scan);
|
|
$builder->build();
|
|
ignore_user_abort(false);
|
|
}
|
|
}
|