function empty_class_call($inst, $method_name, $arguments){
$r = false;
- $args = "";
- foreach($arguments as $i => $arg) $args .= ($args ? ", " : "")."\$arguments[".$i."]";
- if(isset($inst->modules)) foreach($inst->modules as $module_name => $module){
- if(method_exists($module, $method_name)){
- eval("\$r = \$module->".$method_name."(".$args.");");
+ if(($module = $this->get_module_for_method($inst, $method_name)) !== false){
+ $args = ""; foreach($arguments as $i => $arg) $args .= ($args ? ", " : "")."\$arguments[".$i."]";
+ eval("\$r = \$module->".$method_name."(".$args.");");
+ }
+ else $r = $this->call_default($inst, $method_name, $arguments);
+ return $r;
+ }
+
+ function get_module_for_method($inst, $method_name){
+ $module = false;
+ if(isset($inst->modules)) foreach($inst->modules as $module_name => $module_impl){
+ if(method_exists($module_impl, $method_name)){
+ $module = $module_impl;
break;
}
else{
- $r = $this->empty_class_call($module, $method_name, $arguments);
- if($r !== false) break;
+ $module = $this->get_module_for_method($module_impl, $method_name);
+ if($module !== false) break;
}
}
- return $r;
+ return $module;
+ }
+
+ function call_default($inst, $method_name, $arguments){
+ return false;
}
}