/** * Generates a WebDAV propfind response body based on a list of nodes. * * If 'strip404s' is set to true, all 404 responses will be removed. * * @param array $fileProperties The list with nodes * @param bool strip404s * @return string */ function generateMultiStatus(array $fileProperties, $strip404s = false) { $xml = []; foreach ($fileProperties as $entry) { $href = $entry['href']; unset($entry['href']); if ($strip404s) { unset($entry[404]); } $response = new Xml\Element\Response( ltrim($href, '/'), $entry ); $xml[] = [ 'name' => '{DAV:}response', 'value' => $response ]; } return $this->xml->write('{DAV:}multistatus', $xml, $this->baseUri); }
/** * @param string $body * @return array * @throws \Sabre\Xml\ParseException */ private function parseMultiStatus($body) { $xml = new Service(); /** @var MultiStatus $multiStatus */ $multiStatus = $xml->expect('{DAV:}multistatus', $body); $result = []; foreach ($multiStatus->getResponses() as $response) { $result[$response->getHref()] = $response->getResponseProperties(); } return ['response' => $result, 'token' => $multiStatus->getSyncToken()]; }