ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
XML_RPC2_Backend_Xmlrpcext_Value Class Reference
+ Collaboration diagram for XML_RPC2_Backend_Xmlrpcext_Value:

Static Public Member Functions

static createFromNative ($value, $explicitType)
 Factory method that constructs the appropriate XML-RPC encoded type value. More...
 

Detailed Description

Definition at line 57 of file Value.php.

Member Function Documentation

◆ createFromNative()

static XML_RPC2_Backend_Xmlrpcext_Value::createFromNative (   $value,
  $explicitType 
)
static

Factory method that constructs the appropriate XML-RPC encoded type value.

Parameters
mixedValue to be encode
stringExplicit XML-RPC type as enumerated in the XML-RPC spec (defaults to automatically selected type)
Returns
mixed The encoded value

Definition at line 69 of file Value.php.

70 {
71 $type = strtolower($explicitType);
72 $availableTypes = array('datetime', 'base64', 'struct');
73 if (in_array($type, $availableTypes)) {
74 if ($type=='struct') {
75 if (!(is_array($value))) {
76 throw new XML_RPC2_Exception('With struct type, value has to be an array');
77 }
78 // Because of http://bugs.php.net/bug.php?id=21949
79 // is some cases (structs with numeric indexes), we need to be able to force the "struct" type
80 // (xmlrpc_set_type doesn't help for this, so we need this ugly hack)
81 $new = array();
82 while (list($k, $v) = each($value)) {
83 $new["xml_rpc2_ugly_struct_hack_$k"] = $v;
84 // with this "string" prefix, we are sure that the array will be seen as a "struct"
85 }
86 return $new;
87 }
88 $value2 = (string) $value;
89 if (!xmlrpc_set_type($value2, $type)) {
90 throw new XML_RPC2_Exception('Error returned from xmlrpc_set_type');
91 }
92 return $value2;
93 }
94 return $value;
95 }

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