private function decodeBinaryDom($xml)
{
$dom = new DOMDocument();
if (!$dom->loadXML($xml)) {
throw new RepositoryException("Failed to load xml data:\n\n{$xml}");
}
$ret = array();
foreach ($dom->getElementsByTagNameNS(self::NS_DCR, 'values') as $node) {
foreach ($node->getElementsByTagNameNS(self::NS_DCR, 'value') as $value) {
if ($value->getAttributeNS(self::NS_DCR, 'type') != PropertyType::TYPENAME_BINARY) {
throw new RepositoryException('Expected binary value but got ' . $value->getAttributeNS(self::NS_DCR, 'type'));
}
// TODO: OPTIMIZE stream handling!
$stream = fopen('php://memory', 'rwb+');
fwrite($stream, base64_decode($value->textContent));
rewind($stream);
$ret[] = $stream;
}
}
return $ret;
}