示例#1
0
 /**
  * WebDAV HTTP COPY method
  *
  * This method copies one uri to a different uri, and works much like the MOVE request
  * A lot of the actual request processing is done in getCopyMoveInfo
  *
  * @param string $uri
  * @return bool
  */
 protected function httpCopy($uri)
 {
     $copyInfo = $this->getCopyAndMoveInfo();
     // If the destination is part of the source tree, we must fail
     if ($copyInfo['destination'] == $uri) {
         throw new Exception\Forbidden('Source and destination uri are identical.');
     }
     if ($copyInfo['destinationExists']) {
         if (!$this->broadcastEvent('beforeUnbind', array($copyInfo['destination']))) {
             return false;
         }
         $this->tree->delete($copyInfo['destination']);
     }
     if (!$this->broadcastEvent('beforeBind', array($copyInfo['destination']))) {
         return false;
     }
     $this->tree->copy($uri, $copyInfo['destination']);
     $this->broadcastEvent('afterBind', array($copyInfo['destination']));
     // If a resource was overwritten we should send a 204, otherwise a 201
     $this->httpResponse->setHeader('Content-Length', '0');
     $this->httpResponse->sendStatus($copyInfo['destinationExists'] ? 204 : 201);
 }