Router я мог вызвать переменную $module->acl, но только как будто эта переменная есть в классе родителя ($this->acl;)class Module {
public function share($moduleName, $func) {
$this->$moduleName = $func();
}
}$module = new Module();
$module->share('router', function(){
return new Router();
});
$module->share('acl', function(){
return new ACL();
});class Router {
public function isAllowed() {
$this->acl->isAllowed("user", "Controller");
}
} class Module {
public function share($moduleName, $func) {
$this->$moduleName = $func();
}
}$module = new Module();
$module->share('router', function(){
return new Router();
});
$module->share('acl', function(){
return new ACL();
});