Exemple #1
0
 /**
  * @static
  * @return REST_Client
  */
 public static function instance()
 {
     if (self::$self == NULL) {
         self::$self = new self();
     }
     return self::$self;
 }
Exemple #2
0
 function setUp()
 {
     $this->sync = REST_Client::factory('sync', array('verbose' => false));
     $this->async = REST_Client::factory('async', array('verbose' => false));
     if (getenv('http_proxy')) {
         $this->http_proxy = getenv('http_proxy');
     }
 }
 function test_hook_modify()
 {
     $this->hook_flags = array();
     $rest = REST_Client::factory('async', array('verbose' => false))->addFireHook(array($this, 'fire_hook_modify'))->addFetchHook(array($this, 'fetch_hook_modify'));
     $r = REST_Request::newInstance()->setProtocol('http')->setHost($this->test_host)->setPort($this->test_port);
     $rest->fire($r->get('/'));
     $resp = $rest->fetch();
     $this->assertEquals('/mymodifiedurl', $r->getUrl());
     $this->assertEquals(404, $resp->code);
 }
Exemple #4
0
 public function apiProxy()
 {
     if (!is_array($this->oSetVO->oProxyRequest->data)) {
         throw new Exception('Request is not a array.');
     }
     $haveYar = FALSE;
     foreach ($this->oSetVO->oProxyRequest->data as $id => $this->oRequestEntity) {
         switch ($this->oRequestEntity->method) {
             case Constants_ConcurrentEnum::METHOD_REST_GET:
             case Constants_ConcurrentEnum::METHOD_REST_POST:
                 $this->restClient->setApi($this->oRequestEntity->api);
                 $this->restClient->setMethod($this->oRequestEntity->method);
                 $this->restClient->setData($this->oRequestEntity->params);
                 $this->restClient->go();
                 $tmp = $this->restClient->getBody();
                 self::$responseResult[$this->oRequestEntity->identifier] = $tmp;
                 break;
             case Constants_ConcurrentEnum::METHOD_RPC_YAR:
                 $haveYar = TRUE;
                 $params = array('identifier' => $this->oRequestEntity->identifier);
                 $this->oRequestEntity->params = array(array_merge($params, $this->oRequestEntity->params));
                 Yar_Concurrent_Client::call($this->oRequestEntity->api, $this->oRequestEntity->function, $this->oRequestEntity->params, "Services_Concurrent_Transaction::callBack");
                 break;
         }
     }
     if ($haveYar) {
         Yar_Concurrent_Client::loop("Services_Concurrent_Transaction::callBack", "Services_Concurrent_Transaction::errorCallBack");
     }
     return self::$responseResult;
 }
Exemple #5
0
 public function init()
 {
     $validator = new BaseValid();
     $validator->executeFilterMethod($this->getRequest());
     $this->check = REST_Check::instance();
     $this->rest = REST_Server::instance();
     $this->client = REST_Client::instance();
     $this->params = array_merge($_POST, $_GET);
     //$this->db       = DB_Contect::db();
     //$this->quantity = REST_Quantity::instance();
     //$this->modified = REST_Modified::instance();
     // $this->session  = Yaf_Session::getInstance();
     // $this->mkData   = REST_Mkdata::instance();
     //  $this->setScaffoldConfig();
     //  $this->ScaffoldRoute();
     //$this->setConfig();
 }
Exemple #6
0
 public function __construct($host = 'localhost', $port = 80, $options = array())
 {
     $this->request = REST_Request::newInstance()->setProtocol('http')->setHost($host)->setPort($port)->setCurlOptions($options);
     $this->client = REST_Client::factory('sync', array('verbose' => false));
 }
Exemple #7
0
 public function __construct()
 {
     $this->oSetVO = Services_Widget_SetVO::instance();
     $this->client = REST_Client::instance();
 }