putDocument() public method

public putDocument ( Path $p, $contentType, $documentData, array $ifMatch = null, array $ifNoneMatch = null )
$p Path
$ifMatch array
$ifNoneMatch array
 public function putDocument(Request $request, TokenInfo $tokenInfo)
 {
     $path = new Path($request->getUrl()->getPathInfo());
     if ($path->getUserId() !== $tokenInfo->getUserId()) {
         throw new ForbiddenException('path does not match authorized subject');
     }
     if (!$this->hasWriteScope($tokenInfo->getScope(), $path->getModuleName())) {
         throw new ForbiddenException('path does not match authorized scope');
     }
     $ifMatch = $this->stripQuotes($request->getHeader('If-Match'));
     $ifNoneMatch = $this->stripQuotes($request->getHeader('If-None-Match'));
     $documentVersion = $this->remoteStorage->getVersion($path);
     if (null !== $ifMatch && !in_array($documentVersion, $ifMatch)) {
         throw new PreconditionFailedException('version mismatch');
     }
     if (null !== $ifNoneMatch && in_array('*', $ifNoneMatch) && null !== $documentVersion) {
         throw new PreconditionFailedException('document already exists');
     }
     $x = $this->remoteStorage->putDocument($path, $request->getHeader('Content-Type'), $request->getBody(), $ifMatch, $ifNoneMatch);
     // we have to get the version again after the PUT
     $documentVersion = $this->remoteStorage->getVersion($path);
     $rsr = new Response();
     $rsr->setHeader('ETag', '"' . $documentVersion . '"');
     $rsr->setBody($x);
     return $rsr;
 }