mirror of
https://github.com/Lastorder-DC/rhymix.git
synced 2026-04-03 10:32:12 +09:00
NOISSUE, Adding the magic class value. a module can get a MVC object of module by special member value like $this->o{ModuleName}{Type} in each Module Class extended ModuleObject Class.
eg) $oDocumentModel = $this->oDocumentModel; instead of $oDocumentModel = getModel('document');
$oDocumentAdminController = $this->oDocumentAdminController; instead of $oDocumentAdminController = getAdminController('document');
This commit is contained in:
parent
bc47f19615
commit
de30ecfb39
1 changed files with 22 additions and 1 deletions
|
|
@ -27,6 +27,8 @@ class ModuleObject extends Object
|
|||
var $ajaxRequestMethod = array('XMLRPC', 'JSON');
|
||||
var $gzhandler_enable = TRUE;
|
||||
|
||||
private static $_oModules = array();
|
||||
|
||||
/**
|
||||
* setter to set the name of module
|
||||
* @param string $module name of module
|
||||
|
|
@ -477,5 +479,24 @@ class ModuleObject extends Object
|
|||
return true;
|
||||
}
|
||||
|
||||
function __get($name)
|
||||
{
|
||||
if($name{0} !== 'o' || !isset($name{7})) return NULL;
|
||||
if(isset(self::$_oModules[$name])) return self::$_oModules[$name];
|
||||
|
||||
$types = array('Model', 'Controller', 'View', 'AdminModel', 'AdminController', 'AdminView');
|
||||
foreach($types as $type)
|
||||
{
|
||||
$func = 'get' . $type;
|
||||
if(FALSE !== ($pos=strpos($name, $type)) && 2 < $pos && ($oModule = $func(strtolower(substr($name, 1, $pos-1)))))
|
||||
{
|
||||
self::$_oModules[$name] = $oModule;
|
||||
return $oModule;
|
||||
}
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
?>
|
||||
/* End of file ModuleObject.class.php */
|
||||
/* Location: ./classes/module/ModuleObject.class.php */
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue