gluu
公開メンバ関数 | 限定公開変数類 | 静的限定公開変数類 | 全メンバ一覧
GluuOxd_Gluufolder_Helper_ClientOXDRP クラス
GluuOxd_Gluufolder_Helper_ClientOXDRP の継承関係図
Inheritance graph
GluuOxd_Gluufolder_Helper_ClientOXDRP 連携図
Collaboration graph

公開メンバ関数

 __construct ()
 
 oxd_socket_request ($data, $char_count=8192)
 
 request ()
 
 getResponseData ()
 
 getData ()
 
 getCommand ()
 
 setCommand ()
 
 getResponseObject ()
 
 getResponseJSON ()
 
 setParams ()
 
 getParams ()
 

限定公開変数類

 $data = array()
 
 $command
 
 $params = array()
 
 $response_json
 
 $response_object
 
 $response_data = array()
 

静的限定公開変数類

static $socket = null
 

詳解

構築子と解体子

◆ __construct()

GluuOxd_Gluufolder_Helper_ClientOXDRP::__construct ( )

abstract Client_oxd constructor.

74  {
75  $this->setCommand();
76  }

関数詳解

◆ getCommand()

GluuOxd_Gluufolder_Helper_ClientOXDRP::getCommand ( )
戻り値
string
163  {
164  return $this->command;
165  }
$command
Definition: ClientOXDRP.php:62

◆ getData()

GluuOxd_Gluufolder_Helper_ClientOXDRP::getData ( )
戻り値
array
154  {
155  $this->data = array('command' => $this->getCommand(), 'params' => $this->getParams());
156  return $this->data;
157  }
getCommand()
Definition: ClientOXDRP.php:162
$data
Definition: ClientOXDRP.php:61
getParams()
Definition: ClientOXDRP.php:198

◆ getParams()

GluuOxd_Gluufolder_Helper_ClientOXDRP::getParams ( )
戻り値
array
199  {
200  return $this->params;
201  }
$params
Definition: ClientOXDRP.php:63

◆ getResponseData()

GluuOxd_Gluufolder_Helper_ClientOXDRP::getResponseData ( )
戻り値
mixed
140  {
141  if (!$this->getResponseObject()) {
142  $this->response_data = 'Data is empty';
143  return;
144  } else {
145  $this->response_data = $this->getResponseObject()->data;
146  }
147  return $this->response_data;
148  }
getResponseObject()
Definition: ClientOXDRP.php:176
$response_data
Definition: ClientOXDRP.php:66

◆ getResponseJSON()

GluuOxd_Gluufolder_Helper_ClientOXDRP::getResponseJSON ( )

function getting result from oxD server. return: response_json - The JSON response from the oxD Server

186  {
187  return $this->response_json;
188  }
$response_json
Definition: ClientOXDRP.php:64

◆ getResponseObject()

GluuOxd_Gluufolder_Helper_ClientOXDRP::getResponseObject ( )

getResult function geting result from oxD server. Return: response_object - The JSON response parsing to object

177  {
178  return $this->response_object;
179  }
$response_object
Definition: ClientOXDRP.php:65

◆ oxd_socket_request()

GluuOxd_Gluufolder_Helper_ClientOXDRP::oxd_socket_request (   $data,
  $char_count = 8192 
)

request to oxd socket

80  {
81  $oxd_config = json_decode(Mage::getStoreConfig('gluu/oxd/gluu_config'), true);
82  self::$socket = stream_socket_client('127.0.0.1:' . $oxd_config['gluu_oxd_port'], $errno, $errstr, STREAM_CLIENT_PERSISTENT);
83  if (!self::$socket) {
84  return 'Can not connect to oxd server';
85  }else{
86  fwrite(self::$socket, $data);
87  $result = fread(self::$socket, $char_count);
88  fclose(self::$socket);
89  return $result;
90  }
91 
92  }
$data
Definition: ClientOXDRP.php:61

◆ request()

GluuOxd_Gluufolder_Helper_ClientOXDRP::request ( )

send function sends the command to the oxD server.

Args: command (dict) - Dict representation of the JSON command string

100  {
101  $this->setParams();
102 
103  $jsondata = json_encode($this->getData(), JSON_UNESCAPED_SLASHES);
104 
105  $lenght = strlen($jsondata);
106  if($lenght<=0){
107  return array('status'=> false, 'message'=> 'Sorry .Problem with oxd.');
108  }else{
109  $lenght = $lenght <= 999 ? "0" . $lenght : $lenght;
110  }
111 
112  $this->response_json = $this->oxd_socket_request(utf8_encode($lenght . $jsondata));
113  if($this->response_json !='Can not connect to oxd server'){
114  $this->response_json = str_replace(substr($this->response_json, 0, 4), "", $this->response_json);
115  if ($this->response_json) {
116  $object = json_decode($this->response_json);
117  if ($object->status == 'error') {
118  if($object->data->error == "invalid_op_host"){
119  return array('status'=> false, 'message'=> $object->data->error);
120  }elseif($object->data->error == "internal_error"){
121  return array('status'=> false, 'message'=> $object->data->error , 'error_message'=>$object->data->error_description);
122  }else{
123  return array('status'=> false, 'message'=> $object->data->error . ' : ' . $object->data->error_description);
124  }
125  } elseif ($object->status == 'ok') {
126  $this->response_object = json_decode($this->response_json);
127  return array('status'=> true);
128  }
129  }
130  }else{
131  return array('status'=> false, 'message'=> 'Can not connect to the oxd server. Please check the oxd-config.json file to make sure you have entered the correct port and the oxd server is operational.');
132  }
133 
134  }
getData()
Definition: ClientOXDRP.php:153
oxd_socket_request($data, $char_count=8192)
Definition: ClientOXDRP.php:80

◆ setCommand()

GluuOxd_Gluufolder_Helper_ClientOXDRP::setCommand ( )
abstract
引数
string$command

◆ setParams()

GluuOxd_Gluufolder_Helper_ClientOXDRP::setParams ( )
abstract
引数
array$params

メンバ詳解

◆ $command

GluuOxd_Gluufolder_Helper_ClientOXDRP::$command
protected

◆ $data

GluuOxd_Gluufolder_Helper_ClientOXDRP::$data = array()
protected

◆ $params

GluuOxd_Gluufolder_Helper_ClientOXDRP::$params = array()
protected

◆ $response_data

GluuOxd_Gluufolder_Helper_ClientOXDRP::$response_data = array()
protected

◆ $response_json

GluuOxd_Gluufolder_Helper_ClientOXDRP::$response_json
protected

◆ $response_object

GluuOxd_Gluufolder_Helper_ClientOXDRP::$response_object
protected

◆ $socket

GluuOxd_Gluufolder_Helper_ClientOXDRP::$socket = null
staticprotected

このクラス詳解は次のファイルから抽出されました: