Exemple #1
0
 public function handle($path, Uri $baseUri, HttpRequest $request, StorageInterface $storage)
 {
     if (!$request->isDelete()) {
         return;
     }
     $resource = $storage->findResource($path);
     if ($resource->isCollection() && $request->hasHeader('Depth')) {
         $depth = $request->getHeader('Depth', 'infinity');
         if ($depth != 'infinity') {
             throw new BadRequestException();
         }
     }
     $storage->beginTransaction();
     try {
         $storage->deleteResource($resource);
     } catch (\Exception $e) {
         $storage->rollBack();
         throw $e;
     }
     $storage->commit();
     return new HttpResponse(WebDav::CODE_NO_CONTENT);
 }
Exemple #2
0
 protected function performMove(ResourceInterface $resource, $destination, $overwrite, &$replaced, StorageInterface $storage)
 {
     $parts = explode('/', $destination);
     $name = array_pop($parts);
     try {
         $parent = $storage->findResource(implode('/', $parts));
     } catch (\OutOfBoundsException $e) {
         throw new WebDavException(WebDav::CODE_CONFLICT);
     }
     if (!$parent->isCollection()) {
         throw new WebDavException(WebDav::CODE_CONFLICT);
     }
     try {
         $target = $storage->findResource($destination);
         if ($resource->getPath() == $target->getPath()) {
             throw new WebDavException(WebDav::CODE_FORBIDDEN);
         }
         if (!$overwrite) {
             throw new WebDavException(WebDav::CODE_PRECONDITION_FAILED);
         }
         $storage->deleteResource($target);
         $replaced = true;
     } catch (\OutOfBoundsException $e) {
     }
     return $storage->moveResource($resource, $parent, $name);
 }