]> git.mjollnir.org Git - moodle.git/commitdiff
MDL-12886 zend base class improvements, somebody forgot to update Zend framework...
authorPetr Skoda <skodak@moodle.org>
Sat, 24 Oct 2009 15:28:01 +0000 (15:28 +0000)
committerPetr Skoda <skodak@moodle.org>
Sat, 24 Oct 2009 15:28:01 +0000 (15:28 +0000)
webservice/lib.php
webservice/rest/locallib.php
webservice/rest/server.php
webservice/rest/simpleserver.php
webservice/xmlrpc/locallib.php
webservice/xmlrpc/server.php
webservice/xmlrpc/simpleserver.php

index 5f983231eb8127ca3fadd3009b942cd66d2d77c2..3a5637ed800d0f84a47ed58babd01337747bd843 100644 (file)
@@ -61,10 +61,9 @@ function webservice_protocol_is_enabled($protocol) {
 interface webservice_server {
     /**
      * Process request from client.
-     * @param bool $simple use simple authentication
      * @return void
      */
-    public function run($simple);
+    public function run();
 }
 
 /**
@@ -108,8 +107,10 @@ abstract class webservice_zend_server implements webservice_server {
 
     /**
      * Contructor
+     * @param bool $simple use simple authentication
      */
-    public function __construct($zend_class) {
+    public function __construct($simple, $zend_class) {
+        $this->simple = $simple;
         $this->zend_class = $zend_class;
     }
 
@@ -118,9 +119,7 @@ abstract class webservice_zend_server implements webservice_server {
      * @param bool $simple use simple authentication
      * @return void
      */
-    public function run($simple) {
-        $this->simple = $simple;
-
+    public function run() {
         // we will probably need a lot of memory in some functions
         @raise_memory_limit('128M');
 
@@ -143,9 +142,12 @@ abstract class webservice_zend_server implements webservice_server {
         // make a list of all functions user is allowed to excecute
         $this->init_service_class();
 
-        // start the server
+        // tell server what functions are available
         $this->zend_server->setClass($this->service_class);
+
+        // execute and return response, this sends some headers too
         $response = $this->zend_server->handle();
+
 /*
         $grrr = ob_get_clean();
         error_log($grrr);
@@ -333,14 +335,7 @@ class '.$classname.' {
      * @return void
      */
     protected function init_zend_server() {
-        include "Zend/Loader.php";
-        Zend_Loader::registerAutoload();
-        //TODO: set up some server options and debugging too - maybe a new method
-        //TODO: add some zend exeption handler too
         $this->zend_server = new $this->zend_class();
-
-        // TODO: solve debugging level somehow
-        Zend_XmlRpc_Server_Fault::attachFaultException('moodle_exception');
     }
 
     /**
@@ -499,8 +494,10 @@ abstract class webservice_base_server implements webservice_server {
 
     /**
      * Contructor
+     * @param bool $simple use simple authentication
      */
-    public function __construct() {
+    public function __construct($simple) {
+        $this->simple = $simple;
     }
 
     /**
@@ -528,12 +525,9 @@ abstract class webservice_base_server implements webservice_server {
 
     /**
      * Process request from client.
-     * @param bool $simple use simple authentication
      * @return void
      */
-    public function run($simple) {
-        $this->simple = $simple;
-
+    public function run() {
         // we will probably need a lot of memory in some functions
         @raise_memory_limit('128M');
 
index c6eab0d5a7e32e1d7a673f08d428f0237cf5621d..935852f894c0c4a20401162525c9d4504e165850 100644 (file)
@@ -33,8 +33,8 @@ class webservice_rest_server extends webservice_base_server {
     /**
      * Contructor
      */
-    public function __construct() {
-        parent::__construct();
+    public function __construct($simple) {
+        parent::__construct($simple);
         $this->wsname = 'rest';
     }
 
index 0e9def198dbe800575e571ecb9d8f9f8099bae65..6df08b98653bc0b781d3a8957cb6aaffbbebb3c2 100644 (file)
@@ -32,7 +32,7 @@ if (!webservice_protocol_is_enabled('rest')) {
     die;
 }
 
-$server = new webservice_rest_server();
-$server->run(false);
+$server = new webservice_rest_server(false);
+$server->run();
 die;
 
index 73a5e08e0f1e54a12b29f5a53cc9765df3977f3d..464536ef3b75af35753fd2696c243bafb38d653a 100644 (file)
@@ -32,8 +32,8 @@ if (!webservice_protocol_is_enabled('rest')) {
     die;
 }
 
-$server = new webservice_rest_server();
-$server->run(true);
+$server = new webservice_rest_server(true);
+$server->run();
 die;
 
 
index ea4e7865d2ec10061db62122c1a5fc78233cb517..d356a4c597c6c70b52fd35c0b8e4b5af9c2b446e 100644 (file)
@@ -32,11 +32,23 @@ require_once("$CFG->dirroot/webservice/lib.php");
 class webservice_xmlrpc_server extends webservice_zend_server {
     /**
      * Contructor
+     * @param bool $simple use simple authentication
      */
-    public function __construct() {
-        parent::__construct('Zend_XmlRpc_Server');
+    public function __construct($simple) {
+        require_once 'Zend/XmlRpc/Server.php';
+        parent::__construct($simple, 'Zend_XmlRpc_Server');
         $this->wsname = 'xmlrpc';
     }
+
+    /**
+     * Set up zend serice class
+     * @return void
+     */
+    protected function init_zend_server() {
+        parent::init_zend_server();
+        // this exception indicates request failed
+        Zend_XmlRpc_Server_Fault::attachFaultException('moodle_exception');
+    }
 }
 
 /**
@@ -54,8 +66,7 @@ class webservice_xmlrpc_test_client implements webservice_test_client_interface
         //zend expects 0 based array with numeric indexes
         $params = array_values($params);
 
-        include "Zend/Loader.php";
-        Zend_Loader::registerAutoload();
+        require_once 'Zend/XmlRpc/Client.php';
         $client = new Zend_XmlRpc_Client($serverurl);
         return $client->call($function, $params);
     }
index 0a8bde0251bee4fe2fcb2baa003192e758bdba02..23e2bb4179e0e76b5bb02151661542830972da0b 100644 (file)
@@ -32,7 +32,7 @@ if (!webservice_protocol_is_enabled('xmlrpc')) {
     die;
 }
 
-$server = new webservice_xmlrpc_server();
-$server->run(false);
+$server = new webservice_xmlrpc_server(true);
+$server->run();
 die;
 
index c7a1338b3574f019d473db8deac215104a546b79..d05578fd627d88c35881c0dc2db0650a5d774e9d 100644 (file)
@@ -39,8 +39,8 @@ if (!webservice_protocol_is_enabled('xmlrpc')) {
     die;
 }
 
-$server = new webservice_xmlrpc_server();
-$server->run(true);
+$server = new webservice_xmlrpc_server(true);
+$server->run();
 die;