/**
  * Unserializes the property.
  *
  * This static method should return a an instance of this object.
  *
  * @param \DOMElement $prop
  * @param array $propertyMap
  * @return DAV\IProperty
  */
 static function unserialize(\DOMElement $prop, array $propertyMap)
 {
     $xpath = new \DOMXPath($prop->ownerDocument);
     $xpath->registerNamespace('d', 'urn:DAV');
     // Finding the 'response' element
     $xResponses = $xpath->evaluate('d:response', $prop);
     $result = [];
     for ($jj = 0; $jj < $xResponses->length; $jj++) {
         $xResponse = $xResponses->item($jj);
         // Parsing 'href'
         $href = Href::unserialize($xResponse, $propertyMap);
         $properties = [];
         // Parsing 'status' in 'd:response'
         $responseStatus = $xpath->evaluate('string(d:status)', $xResponse);
         if ($responseStatus) {
             list(, $responseStatus, ) = explode(' ', $responseStatus, 3);
         }
         // Parsing 'propstat'
         $xPropstat = $xpath->query('d:propstat', $xResponse);
         for ($ii = 0; $ii < $xPropstat->length; $ii++) {
             // Parsing 'status'
             $status = $xpath->evaluate('string(d:status)', $xPropstat->item($ii));
             list(, $statusCode, ) = explode(' ', $status, 3);
             $usedPropertyMap = $statusCode == '200' ? $propertyMap : [];
             // Parsing 'prop'
             $properties[$statusCode] = DAV\XMLUtil::parseProperties($xPropstat->item($ii), $usedPropertyMap);
         }
         $result[] = new Response($href->getHref(), $properties, $responseStatus ? $responseStatus : null);
     }
     return new self($result);
 }
Beispiel #2
0
    function testUnserializeIncompatible()
    {
        $xml = '<?xml version="1.0"?>
<d:anything xmlns:d="urn:DAV"><d:href2>/bla/path</d:href2></d:anything>
';
        $dom = new \DOMDocument();
        $dom->loadXML($xml);
        $href = Href::unserialize($dom->firstChild, array());
        $this->assertNull($href);
    }