Move these constants to the batch object
authorMichael J. Rubinsky <mrubinsk@horde.org>
Wed, 18 Feb 2009 01:35:28 +0000 (20:35 -0500)
committerMichael J. Rubinsky <mrubinsk@horde.org>
Wed, 18 Feb 2009 01:35:28 +0000 (20:35 -0500)
framework/Service_Facebook/lib/Horde/Service/Facebook.php
framework/Service_Facebook/lib/Horde/Service/Facebook/BatchRequest.php

index 8f6e68f..be5bd95 100644 (file)
@@ -81,16 +81,11 @@ class Horde_Service_Facebook
     // The current session user
     public $user;
 
-    // Flag to indicate we are in batch mode.
-    protected $_batch_mode;
-
+    // Use only ssl resource flag
+    public $use_ssl_resources = false;
     private $_batchRequest;
 
-//    // Internal call_id counter
-//    protected $_last_call_id = 0;
-
     protected $_base_domain;
-    public $use_ssl_resources = false;
     protected $_call_as_apikey;
 
 
@@ -113,9 +108,6 @@ class Horde_Service_Facebook
     protected $_context;
 
     const API_VALIDATION_ERROR = 1;
-    const BATCH_MODE_DEFAULT = 0;
-    const BATCH_MODE_SERVER_PARALLEL = 0;
-    const BATCH_MODE_SERIAL_ONLY = 2;
     const REST_SERVER_ADDR = 'http://api.facebook.com/restserver.php';
 
     /**
index 6d74246..731da26 100644 (file)
@@ -6,9 +6,33 @@
  */
 class Horde_Service_Facebook_BatchRequest extends Horde_Service_Facebook_Request
 {
+    /**
+     *  Holds pending operations
+     *
+     * @var array
+     */
     private $_queue = array();
-    private $_batchMode = Horde_Service_Facebook::BATCH_MODE_DEFAULT;
 
+    /**
+     * Current mode.
+     *
+     * @var BATCH_MODE_* Constant
+     */
+    private $_batchMode;
+
+    /** BATCH_MODE constants **/
+    const BATCH_MODE_DEFAULT = 0;
+    const BATCH_MODE_SERVER_PARALLEL = 0;
+    const BATCH_MODE_SERIAL_ONLY = 2;
+
+    /**
+     *
+     *
+     * @param $facebook
+     * @param $http_client
+     * @param $params
+     * @return unknown_type
+     */
     public function __construct($facebook, $http_client, $params = array())
     {
         $this->_http = $http_client;
@@ -16,6 +40,8 @@ class Horde_Service_Facebook_BatchRequest extends Horde_Service_Facebook_Request
 
         if (!empty($params['batch_mode'])) {
             $this->_batchMode = $params['batch_mode'];
+        } else {
+            $this->_batchMode = self::BATCH_MODE_DEFAULT;
         }
     }
 
@@ -51,7 +77,7 @@ class Horde_Service_Facebook_BatchRequest extends Horde_Service_Facebook_Request
         }
         $method_feed_json = json_encode($method_feed);
 
-        $serial_only = ($this->_batchMode == Horde_Service_Facebook::BATCH_MODE_SERIAL_ONLY);
+        $serial_only = ($this->_batchMode == self::BATCH_MODE_SERIAL_ONLY);
         $params = array('method_feed' => $method_feed_json,
                         'serial_only' => $serial_only);
         $json = $this->_postRequest('batch.run', $params);