public function buildResponse()
 {
     $response = new HttpResponse(WebDav::CODE_MULTI_STATUS, WebDav::getReason(WebDav::CODE_MULTI_STATUS));
     $response->setHeader('Content-Type', 'application/xml; charset="utf-8"');
     $response->setHeader('Cache-Control', 'no-cache, no-store, must-revalidate, proxy-revalidate');
     if ($this->propfind instanceof PropfindRequest) {
         $response->setEntity([$this, 'streamProperties']);
     } elseif ($this->propfind instanceof PropNameRequest) {
         $response->setEntity([$this, 'streamPropertyNames']);
     } else {
         throw new \RuntimeException('Unable to generate response for ' . get_class($this->propfind));
     }
     return $response;
 }
Example #2
0
 public function streamPropStat($status, array $operations, XmlStreamWriterInterface $xml)
 {
     $xml->startElement(WebDav::NS_DAV, 'propstat');
     $xml->startElement(WebDav::NS_DAV, 'prop');
     foreach ($operations as $operation) {
         $prop = $operation->getPropertyName();
         $xml->writeElement($prop->getNamespaceUri(), $prop->getLocalName());
     }
     $xml->endElement();
     // D:prop
     $xml->writeElement(WebDav::NS_DAV, 'status', sprintf('HTTP/1.1 %u %s', $status, WebDav::getReason($status)));
     if (!empty($prop) && $prop instanceof ProppatchOperationInterface) {
         $result = $prop->getResult();
         if ($result instanceof WebDavConditionException) {
             $xml->startElement(WebDav::NS_DAV, 'error');
             $result->toXml($xml);
             $xml->endElement();
             // D:error
         }
     }
     $xml->endElement();
     // D:propstat
     $xml->flush();
 }
Example #3
0
 public function __construct($status = NULL, \Exception $cause = NULL)
 {
     $status = $status === NULL ? WebDav::CODE_INTERNAL_SERVER_ERROR : $status;
     parent::__construct($status, $cause);
     $this->message = WebDav::getReason($status);
 }