Example #1
0
 public function evaluateCondition(ResourceInterface $resource = NULL)
 {
     if ($this->not) {
         if ($resource === NULL || $resource->isCollection()) {
             return true;
         }
         return (string) $this->etag !== (string) $resource->getEtag();
     }
     if ($resource === NULL || $resource->isCollection()) {
         return false;
     }
     return (string) $this->etag === (string) $resource->getEtag();
 }
 public function streamResourcePropertyNames(ResourceInterface $resource, XmlStreamWriterInterface $xml, $baseUri)
 {
     $xml->startElement(WebDav::NS_DAV, 'response');
     $xml->writeElement(WebDav::NS_DAV, 'href', $baseUri . Uri::encode($resource->getPath()));
     $xml->startElement(WebDav::NS_DAV, 'propstat');
     $xml->startElement(WebDav::NS_DAV, 'prop');
     $xml->writeElement(WebDav::NS_DAV, 'displayname');
     $xml->writeElement(WebDav::NS_DAV, 'getcontenttype');
     $xml->writeElement(WebDav::NS_DAV, 'creationdate');
     $xml->writeElement(WebDav::NS_DAV, 'getlastmodified');
     $xml->writeElement(WebDav::NS_DAV, 'resourcetype');
     if (!$resource->isCollection()) {
         $xml->writeElement(WebDav::NS_DAV, 'getcontentlength');
         $xml->writeElement(WebDav::NS_DAV, 'getetag');
     }
     $xml->writeElement(WebDav::NS_DAV, 'supported-method-set');
     $this->dispatcher->notify(new SerializePropertyNamesEvent($resource, $this->baseUri, $xml));
     $xml->endElement();
     // D:prop
     $xml->writeElement(WebDav::NS_DAV, 'status', 'HTTP/1.1 200 OK');
     $xml->endElement();
     // D:propstat
     $xml->endElement();
     // D:response
     $xml->flush();
 }
Example #3
0
 public function moveResource(ResourceInterface $resource, ResourceInterface $parent, $name)
 {
     if (!$parent->isCollection()) {
         throw new \InvalidArgumentException(sprintf('Parent resource "%s" must be a collection', $parent->getPath()));
     }
     if (!$parent instanceof FilesystemDirectory) {
         throw new \InvalidArgumentException(sprintf('Parent resource "%s" must be a filesystem directory', $parent->getPath()));
     }
     $name = $this->sanitizeResourceName($name);
     $target = $parent->getFileInfo()->getPathname() . DIRECTORY_SEPARATOR . $name;
     if ($resource->isCollection()) {
         if (!$resource instanceof FilesystemDirectory) {
             throw new \InvalidArgumentException(sprintf('Resource "%s" must be a filesystem directory', $resource->getPath()));
         }
         if (!@rename($resource->getFileInfo()->getPathname(), $target)) {
             throw new \RuntimeException('Collection move failed');
         }
         return new FilesystemDirectory($parent->getPath() . '/' . $name, new \SplFileInfo($target), $this);
     }
     if (!$resource instanceof FilesystemFile) {
         throw new \InvalidArgumentException(sprintf('Resource "%s" must be a filesystem file', $resource->getPath()));
     }
     if (!@rename($resource->getFileInfo()->getPathname(), $target)) {
         throw new \RuntimeException('Resource move failed');
     }
     return new FilesystemFile($parent->getPath() . '/' . $name, new \SplFileInfo($target), $this);
 }