ILIAS  release_4-4 Revision
All Data Structures Namespaces Files Functions Variables Modules Pages
XML_RPC2_Backend_Php_Value_Struct Class Reference
+ Inheritance diagram for XML_RPC2_Backend_Php_Value_Struct:
+ Collaboration diagram for XML_RPC2_Backend_Php_Value_Struct:

Public Member Functions

 __construct ($nativeValue)
 Constructor. More...
 
 encode ()
 Encode the instance into XML, for transport. More...
 
- Public Member Functions inherited from XML_RPC2_Backend_Php_Value
 getNativeValue ()
 nativeValue property getter More...
 

Static Public Member Functions

static decode ($xml)
 Decode transport XML and set the instance value accordingly. More...
 
- Static Public Member Functions inherited from XML_RPC2_Backend_Php_Value
static createFromNative ($nativeValue, $explicitType=null)
 Choose a XML_RPC2_Value subclass appropriate for the given value and create it. More...
 
static createFromDecode ($simpleXML)
 Decode an encoded value and build the applicable XML_RPC2_Value subclass. More...
 
- Static Public Member Functions inherited from XML_RPC2_Value
static createFromNative ($value, $explicitType=null)
 Factory method that constructs the appropriate XML-RPC encoded type value. More...
 

Protected Member Functions

 setNativeValue ($value)
 nativeValue property setter More...
 
- Protected Member Functions inherited from XML_RPC2_Backend_Php_Value
 setNativeValue ($value)
 nativeValue setter More...
 

Detailed Description

Definition at line 57 of file Struct.php.

Constructor & Destructor Documentation

◆ __construct()

XML_RPC2_Backend_Php_Value_Struct::__construct (   $nativeValue)

Constructor.

Will build a new XML_RPC2_Backend_Php_Value_Scalar with the given nativeValue

Parameters
mixednativeValue

Definition at line 83 of file Struct.php.

References setNativeValue().

84  {
85  $this->setNativeValue($nativeValue);
86  }
setNativeValue($value)
nativeValue property setter
Definition: Struct.php:67
+ Here is the call graph for this function:

Member Function Documentation

◆ decode()

static XML_RPC2_Backend_Php_Value_Struct::decode (   $xml)
static

Decode transport XML and set the instance value accordingly.

Parameters
mixedThe encoded XML-RPC value,

Definition at line 123 of file Struct.php.

References $result, and XML_RPC2_Backend_Php_Value\createFromDecode().

124  {
125  // TODO Remove reparsing of XML fragment, when SimpleXML proves more solid. Currently it segfaults when
126  // xpath is used both in an element and in one of its children
127  $xml = simplexml_load_string($xml->asXML());
128  $values = $xml->xpath('/value/struct/member');
129  $result = array();
130  foreach (array_keys($values) as $i) {
131  $result[(string) $values[$i]->name] = XML_RPC2_Backend_Php_Value::createFromDecode($values[$i]->value)->getNativeValue();
132  }
133  return $result;
134  }
$result
static createFromDecode($simpleXML)
Decode an encoded value and build the applicable XML_RPC2_Value subclass.
Definition: Value.php:215
+ Here is the call graph for this function:

◆ encode()

XML_RPC2_Backend_Php_Value_Struct::encode ( )

Encode the instance into XML, for transport.

Returns
string The encoded XML-RPC value,

Definition at line 96 of file Struct.php.

References $result, XML_RPC2_Backend_Php_Value\createFromNative(), and XML_RPC2_Backend_Php_Value\getNativeValue().

97  {
98  $result = '<struct>';
99  foreach($this->getNativeValue() as $name => $element) {
100  $result .= '<member>';
101  $result .= '<name>';
102  $result .= strtr($name, array('&' => '&amp;', '<' => '&lt;', '>' => '&gt;'));
103  $result .= '</name>';
104  $result .= '<value>';
105  $result .= ($element instanceof XML_RPC2_Backend_Php_Value) ?
106  $element->encode() :
108  $result .= '</value>';
109  $result .= '</member>';
110  }
111  $result .= '</struct>';
112  return $result;
113  }
$result
static createFromNative($nativeValue, $explicitType=null)
Choose a XML_RPC2_Value subclass appropriate for the given value and create it.
Definition: Value.php:123
getNativeValue()
nativeValue property getter
Definition: Value.php:76
+ Here is the call graph for this function:

◆ setNativeValue()

XML_RPC2_Backend_Php_Value_Struct::setNativeValue (   $value)
protected

nativeValue property setter

Parameters
mixedvalue the new nativeValue

Definition at line 67 of file Struct.php.

Referenced by __construct().

68  {
69  if (!is_array($value)) {
70  throw new XML_RPC2_InvalidTypeException(sprintf('Cannot create XML_RPC2_Backend_Php_Value_Struct from type \'%s\'.', gettype($nativeValue)));
71  }
72  parent::setNativeValue($value);
73  }
+ Here is the caller graph for this function:

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