\Horde_Rpc_Jsonrpc

The Horde_RPC_json-rpc class provides a JSON-RPC 1.1 implementation of the Horde RPC system.

  • Only POST requests are supported.
  • Named and positional parameters are accepted but the Horde registry only works with positional parameters.
  • Service Descriptions are not supported yet.

Summary

Methods
Properties
Constants
__construct()
authorize()
getInput()
getResponse()
getResponseContentType()
sendOutput()
request()
factory()
_raiseError()
_objectsToArrays()
No public properties found
No constants found
No protected methods found
$_params
$_requireAuthorization
$_requestMissingAuthorization
$_request
$_logger
N/A
No private methods found
No private properties found
N/A

Properties

$_params

$_params : array

All driver-specific parameters.

Type

array

$_requireAuthorization

$_requireAuthorization : boolean

Do we need an authenticated user?

Type

boolean

$_requestMissingAuthorization

$_requestMissingAuthorization : boolean

Whether we should exit if auth fails instead of requesting authorization credentials.

Type

boolean

$_request

$_request : \Horde_Controller_Request_Http

Request variables, cookies etc.

..

Type

\Horde_Controller_Request_Http

$_logger

$_logger : \Horde_Log_Logger

Logging

Type

\Horde_Log_Logger

Methods

__construct()

__construct(\Horde_Controller_Request_Http  $request, array  $params = array()) 

Constructor.

Parameters

\Horde_Controller_Request_Http $request

The request object.

array $params

A hash containing any additional configuration or connection parameters a subclass might need.

authorize()

authorize() : boolean

Check authentication. Different backends may handle authentication in different ways. The base class implementation checks for HTTP Authentication against the Horde auth setup.

Returns

boolean —

Returns true if authentication is successful. Should send appropriate "not authorized" headers or other response codes/body if auth fails, and take care of exiting.

getInput()

getInput() : mixed

Get the request body input. Different RPC backends can override this to return an open stream to php://stdin, for instance - whatever is easiest to handle in the getResponse() method.

The base class implementation looks for $HTTP_RAW_POST_DATA and returns that if it's available; otherwise, it returns the contents of php://stdin.

Returns

mixed —

The input - a string (default), a filehandle, etc.

getResponse()

getResponse(  $request) : string

Sends an RPC request to the server and returns the result.

Parameters

$request

Returns

string —

The JSON encoded response from the server.

getResponseContentType()

getResponseContentType() : string

Returns the Content-Type of the response.

Returns

string —

The MIME Content-Type of the RPC response.

sendOutput()

sendOutput(string  $output) : void

Send the output back to the client

Parameters

string $output

The output to send back to the client. Can be overridden in classes if needed.

request()

request(string|\Horde_Url  $url, string  $method, \Horde_Http_Client  $client, array  $params = null) : mixed

Builds an JSON-RPC request and sends it to the server.

This statically called method is actually the JSON-RPC client.

Parameters

string|\Horde_Url $url

The path to the JSON-RPC server on the called host.

string $method

The method to call.

\Horde_Http_Client $client

An appropriate request client for the type of request. (Horde_Http_Request, SoapClient etc..)

array $params

A hash containing any necessary parameters for the method call.

Throws

\Horde_Rpc_Exception

Returns

mixed —

The returned result from the method.

factory()

factory(mixed  $driver,   $request, array  $params = null) : \Horde_Rpc

Attempts to return a concrete RPC server instance based on $driver.

Parameters

mixed $driver

The type of concrete Horde_Rpc subclass to return.

$request
array $params

A hash containing any additional configuration or connection parameters a subclass might need.

Returns

\Horde_Rpc

The newly created concrete Horde_Rpc server instance, or an exception if there is an error.

_raiseError()

_raiseError(string|\PEAR_Error  $error, \stdClass  $request) : \PEAR_Error

Returns a specially crafted PEAR_Error object containing a JSON-RPC response in the error message.

Parameters

string|\PEAR_Error $error

The error message or object.

\stdClass $request

The original request object.

Returns

\PEAR_Error —

An error object suitable for a JSON-RPC 1.1 conform error result.

_objectsToArrays()

_objectsToArrays(  $data) : mixed

Converts stdClass object to associative arrays.

Parameters

$data

mixed Any stdClass object, array, or scalar.

Returns

mixed —

stdClass objects are returned as asscociative arrays, scalars as-is, and arrays with their elements converted.