aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/inc/remote.php
diff options
context:
space:
mode:
authorDominik Eckelmann <deckelmann@gmail.com>2012-02-05 12:36:19 +0100
committerDominik Eckelmann <deckelmann@gmail.com>2012-02-05 12:36:19 +0100
commit03d7247e047c21d2733f837148a1499f56784ae3 (patch)
tree114aa46677624af59fb94f9cd278288932bcaa57 /inc/remote.php
parent750a55de568a82aaa40ca384a17a64804e94f2b9 (diff)
downloaddokuwiki-03d7247e047c21d2733f837148a1499f56784ae3.tar.gz
dokuwiki-03d7247e047c21d2733f837148a1499f56784ae3.zip
moved plugin and core method calls to seperate function
Diffstat (limited to 'inc/remote.php')
-rw-r--r--inc/remote.php38
1 files changed, 23 insertions, 15 deletions
diff --git a/inc/remote.php b/inc/remote.php
index 82a0d3c08..105969f8b 100644
--- a/inc/remote.php
+++ b/inc/remote.php
@@ -82,23 +82,31 @@ class RemoteAPI {
}
list($type, $pluginName, $call) = explode('.', $method, 3);
if ($type === 'plugin') {
- $plugin = plugin_load('remote', $pluginName);
- $methods = $this->getPluginMethods();
- if (!$plugin) {
- throw new RemoteException('Method dose not exists');
- }
- $this->checkAccess($methods[$method]);
- $name = $this->getMethodName($methods, $method);
- return call_user_func_array(array($plugin, $name), $args);
+ return $this->callPlugin($pluginName, $method, $args);
} else {
- $coreMethods = $this->getCoreMethods();
- $this->checkAccess($coreMethods[$method]);
- if (!isset($coreMethods[$method])) {
- throw new RemoteException('Method dose not exists');
- }
- $this->checkArgumentLength($coreMethods[$method], $args);
- return call_user_func_array(array($this->coreMethods, $this->getMethodName($coreMethods, $method)), $args);
+ return $this->callCoreMethod($method, $args);
+ }
+ }
+
+ private function callPlugin($pluginName, $method, $args) {
+ $plugin = plugin_load('remote', $pluginName);
+ $methods = $this->getPluginMethods();
+ if (!$plugin) {
+ throw new RemoteException('Method dose not exists');
+ }
+ $this->checkAccess($methods[$method]);
+ $name = $this->getMethodName($methods, $method);
+ return call_user_func_array(array($plugin, $name), $args);
+ }
+
+ private function callCoreMethod($method, $args) {
+ $coreMethods = $this->getCoreMethods();
+ $this->checkAccess($coreMethods[$method]);
+ if (!isset($coreMethods[$method])) {
+ throw new RemoteException('Method dose not exists');
}
+ $this->checkArgumentLength($coreMethods[$method], $args);
+ return call_user_func_array(array($this->coreMethods, $this->getMethodName($coreMethods, $method)), $args);
}
private function checkAccess($methodMeta) {