ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
Prop.php
Go to the documentation of this file.
1 <?php
2 
4 
8 
20 class Prop implements XmlDeserializable {
21 
43  static function xmlDeserialize(Reader $reader) {
44 
45  // If there's no children, we don't do anything.
46  if ($reader->isEmptyElement) {
47  $reader->next();
48  return [];
49  }
50 
51  $values = [];
52 
53  $reader->read();
54  do {
55 
56  if ($reader->nodeType === Reader::ELEMENT) {
57 
58  $clark = $reader->getClark();
59  $values[$clark] = self::parseCurrentElement($reader)['value'];
60 
61  } else {
62  $reader->read();
63  }
64 
65  } while ($reader->nodeType !== Reader::END_ELEMENT);
66 
67  $reader->read();
68 
69  return $values;
70 
71  }
72 
86  private static function parseCurrentElement(Reader $reader) {
87 
88  $name = $reader->getClark();
89 
90  if (array_key_exists($name, $reader->elementMap)) {
91  $deserializer = $reader->elementMap[$name];
92  if (is_subclass_of($deserializer, 'Sabre\\Xml\\XmlDeserializable')) {
93  $value = call_user_func([$deserializer, 'xmlDeserialize'], $reader);
94  } elseif (is_callable($deserializer)) {
95  $value = call_user_func($deserializer, $reader);
96  } else {
97  $type = gettype($deserializer);
98  if ($type === 'string') {
99  $type .= ' (' . $deserializer . ')';
100  } elseif ($type === 'object') {
101  $type .= ' (' . get_class($deserializer) . ')';
102  }
103  throw new \LogicException('Could not use this type as a deserializer: ' . $type);
104  }
105  } else {
106  $value = Complex::xmlDeserialize($reader);
107  }
108 
109  return [
110  'name' => $name,
111  'value' => $value,
112  ];
113 
114  }
115 
116 }
static xmlDeserialize(Reader $reader)
The deserialize method is called during xml parsing.
Definition: Prop.php:43
$type
static parseCurrentElement(Reader $reader)
This function behaves similar to Sabre::parseCurrentElement, but instead of creating deep xml array s...
Definition: Prop.php:86
The Reader class expands upon PHP&#39;s built-in XMLReader.
Definition: Reader.php:20
$values
Implementing the XmlDeserializable interface allows you to use a class as a deserializer for a specif...
static xmlDeserialize(Reader $reader)
The deserialize method is called during xml parsing.
Definition: Complex.php:41
This class is responsible for decoding the {DAV:}prop element as it appears in {DAV:}property-update...
Definition: Prop.php:20
getClark()
Returns the current nodename in clark-notation.
Definition: Reader.php:34