Moodle PHP Documentation 4.4
Moodle 4.4.1 (Build: 20240610) (db07c09afc5)
PhpXmlRpc\Request Class Reference

Public Member Functions

 __construct ($methodName, $params=array())
 
__get ($name)
 
 __isset ($name)
 
 __set ($name, $value)
 
 __unset ($name)
 
 addParam ($param)
 Add a parameter to the list of parameters to be used upon method invocation.
 
 createPayload ($charsetEncoding='')
 
 getNumParams ()
 Returns the number of parameters in the message.
 
 getParam ($i)
 Returns the nth parameter in the request.
 
 kindOf ()
 Kept the old name even if Request class was renamed, for BC.
 
 method ($methodName='')
 Gets/sets the xml-rpc method to be invoked.
 
 parseResponse ($data='', $headersProcessed=false, $returnType=XMLParser::RETURN_XMLRPCVALS)
 Parse the xml-rpc response contained in the string $data and return a Response object.
 
 parseResponseFile ($fp, $headersProcessed=false, $returnType='xmlrpcvals')
 Given an open file handle, read all data available and parse it as an xml-rpc response.
 
 serialize ($charsetEncoding='')
 Returns xml representation of the message, XML prologue included.
 
 setDebug ($level)
 Enables/disables the echoing to screen of the xml-rpc responses received.
 
 xml_footer ()
 
 xml_header ($charsetEncoding='')
 

Protected Attributes

int $debug = 0
 
string $methodname
 
Value[] $params = array()
 

Constructor & Destructor Documentation

◆ __construct()

PhpXmlRpc\Request::__construct ( $methodName,
$params = array() )
Parameters
string$methodNamethe name of the method to invoke
Value[]$paramsarray of parameters to be passed to the method (NB: Value objects, not plain php values)

Member Function Documentation

◆ addParam()

PhpXmlRpc\Request::addParam ( $param)

Add a parameter to the list of parameters to be used upon method invocation.

Checks that $params is actually a Value object and not a plain php value.

Parameters
Value$param
Return values
booleanfalse on failure

◆ getNumParams()

PhpXmlRpc\Request::getNumParams ( )

Returns the number of parameters in the message.

Return values
integerthe number of parameters currently set

◆ getParam()

PhpXmlRpc\Request::getParam ( $i)

Returns the nth parameter in the request.

The index zero-based.

Parameters
integer$ithe index of the parameter to fetch (zero based)
Return values
Valuethe i-th parameter

◆ kindOf()

PhpXmlRpc\Request::kindOf ( )

Kept the old name even if Request class was renamed, for BC.

Return values
string

◆ method()

PhpXmlRpc\Request::method ( $methodName = '')

Gets/sets the xml-rpc method to be invoked.

Parameters
string$methodNamethe method to be set (leave empty not to set it)
Return values
stringthe method that will be invoked

◆ parseResponse()

PhpXmlRpc\Request::parseResponse ( $data = '',
$headersProcessed = false,
$returnType = XMLParser::RETURN_XMLRPCVALS )

Parse the xml-rpc response contained in the string $data and return a Response object.

When $this->debug has been set to a value greater than 0, will echo debug messages to screen while decoding.

Parameters
string$datathe xml-rpc response, possibly including http headers
bool$headersProcessedwhen true prevents parsing HTTP headers for interpretation of content-encoding and consequent decoding
string$returnTypedecides return type, i.e. content of response->value(). Either 'xmlrpcvals', 'xml' or 'phpvals'
Return values
Response
Todo

parsing Responses is not really the responsibility of the Request class. Maybe of the Client...

what about only populating 'raw_data' in httpResponse when debug mode is > 0?

feature creep - allow parsing data gotten from a stream pointer instead of a string: read it piecewise, looking first for separation between headers and body, then for charset indicators, server debug info and </methodResponse>. That would require a notable increase in code complexity...

◆ parseResponseFile()

PhpXmlRpc\Request::parseResponseFile ( $fp,
$headersProcessed = false,
$returnType = 'xmlrpcvals' )

Given an open file handle, read all data available and parse it as an xml-rpc response.

NB: the file handle is not closed by this function. NNB: might have trouble in rare cases to work on network streams, as we check for a read of 0 bytes instead of feof($fp). But since checking for feof(null) returns false, we would risk an infinite loop in that case, because we cannot trust the caller to give us a valid pointer to an open file...

Parameters
resource$fpstream pointer
bool$headersProcessed
string$returnType
Return values
Response
Todo

arsing Responses is not really the responsibility of the Request class. Maybe of the Client...

feature creep - add a flag to disable trying to parse the http headers

◆ serialize()

PhpXmlRpc\Request::serialize ( $charsetEncoding = '')

Returns xml representation of the message, XML prologue included.

Sets payload and content_type properties

Parameters
string$charsetEncoding
Return values
stringthe xml representation of the message, xml prologue included

◆ setDebug()

PhpXmlRpc\Request::setDebug ( $level)

Enables/disables the echoing to screen of the xml-rpc responses received.

Parameters
integer$levelvalues <0, 0, 1, >1 are supported
Return values
$this

The documentation for this class was generated from the following file: