public function callAppMethod($app, $call, array $options = array())
{
/* Load the API now. */
try {
$api = $this->getApiInstance($app, 'application');
} catch (Horde_Exception $e) {
if (empty($options['check_missing'])) {
return null;
}
throw $e;
}
if (!method_exists($api, $call)) {
if (empty($options['check_missing'])) {
return null;
}
throw new Horde_Exception('Method does not exist.');
}
/* Switch application contexts now, if necessary, before
* including any files which might do it for us. Return an
* error immediately if pushApp() fails. */
$pushed = $this->pushApp($app, array('check_perms' => empty($options['noperms']) && $this->currentProcessAuth()));
try {
$result = call_user_func_array(array($api, $call), empty($options['args']) ? array() : $options['args']);
} catch (Horde_Exception $e) {
$result = $e;
}
/* If we changed application context in the course of this
* call, undo that change now. */
if ($pushed === true) {
$this->popApp();
}
if ($result instanceof Exception) {
throw $e;
}
return $result;
}