Refactor PHP setup.

This commit is contained in:
Lars Jung 2015-05-02 16:52:50 +02:00
parent 77d6da3a24
commit 6e54ba2f73
2 changed files with 32 additions and 12 deletions

View file

@ -2,12 +2,11 @@
class Api {
private $actions, $app;
private $app;
public function __construct($app) {
$this->actions = array("login", "logout", "get", "getThumbHref", "download");
$this->app = $app;
}
@ -15,7 +14,8 @@ class Api {
public function apply() {
$action = Util::get_request_param("action");
Util::json_fail(Util::RC_UNSUPPORTED, "unsupported action", !in_array($action, $this->actions));
$supported = array("login", "logout", "get", "getThumbHref", "download");
Util::json_fail(Util::RC_UNSUPPORTED, "unsupported action", !in_array($action, $supported));
$methodname = "on_${action}";
$this->$methodname();