public Object call(Object object, String method, Object[] args) throws BSFException {
Env env = php.createEnv(null, null, null, null);
env.start();
populateEnv(env);
Value v = null;
PHPEvalWrapper phpw = null;
if(object instanceof PHPEvalWrapper){
phpw = (PHPEvalWrapper)object;
}else{
phpw = (PHPEvalWrapper)eval(object.toString(), -1, -1, "");
}
List<Function> funs = phpw.getFunctions();
Value[] values = null;
if(args != null){
values = new Value[args.length];
for (int i = 0; i < args.length; i++) {
Object o = args[i];
values[i] = env.wrapJava(o);
}
}
try{
if(funs != null && funs.size() > 0){
v = callFunctionFromFunctionList(funs, method, env, values);
}else{
v = callFunctionOnPage(phpw.getPage(), method, env, values);
}
}catch (Exception e) {
Logger.error(this, e.getMessage(),e );
throw new BSFException("Unable to find function name " + method != null ? method : "" + " to call");
}