mirror of
https://github.com/Lastorder-DC/rhymix.git
synced 2026-01-03 16:51:40 +09:00
모듈 클래스 로딩에서 autoload를 사용할 수 있도록 함
This commit is contained in:
parent
cc572122b2
commit
d0753e746b
2 changed files with 14 additions and 19 deletions
|
|
@ -1043,31 +1043,18 @@ class ModuleHandler extends Handler
|
|||
ModuleHandler::_getModuleFilePath($module, $type, $kind, $class_path, $high_class_file, $class_file, $instance_name);
|
||||
}
|
||||
|
||||
// Get base class name and load the file contains it
|
||||
if(!class_exists($module, false))
|
||||
// Check if the base class and instance class exist
|
||||
if(!class_exists($module, true))
|
||||
{
|
||||
$high_class_file = sprintf('%s%s%s.class.php', _XE_PATH_, $class_path, $module);
|
||||
if(!file_exists($high_class_file))
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
require_once($high_class_file);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
// Get the name of the class file
|
||||
if(!is_readable($class_file))
|
||||
if(!class_exists($instance_name, true))
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
// Create an instance with eval function
|
||||
require_once($class_file);
|
||||
if(!class_exists($instance_name, false))
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
$tmp_fn = create_function('', "return new {$instance_name}();");
|
||||
$oModule = $tmp_fn();
|
||||
// Create an instance
|
||||
$oModule = new $instance_name();
|
||||
if(!is_object($oModule))
|
||||
{
|
||||
return NULL;
|
||||
|
|
|
|||
|
|
@ -332,6 +332,14 @@ if(!defined('__XE_LOADED_CLASS__'))
|
|||
{
|
||||
require _XE_PATH_ . $GLOBALS['__xe_autoload_file_map'][$class_name];
|
||||
}
|
||||
elseif(preg_match('/^([a-z0-9_]+?)(admin)?(view|controller|model|api|wap|mobile)?$/i', $class_name, $matches))
|
||||
{
|
||||
$candidate_filename = 'modules/' . $matches[1] . '/' . $matches[1] . ($matches[2] ? '.admin' : '') . ($matches[3] ? ('.' . $matches[3]) : '.class') . '.php';
|
||||
if(file_exists(_XE_PATH_ . $candidate_filename))
|
||||
{
|
||||
require _XE_PATH_ . $candidate_filename;
|
||||
}
|
||||
}
|
||||
}
|
||||
spl_autoload_register('__xe_autoload');
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue