Example #1
0
 /**
  * {@inheritdoc}
  */
 public function jsonSerialize()
 {
     $namespace = $this->location->getNamespace();
     $data = [$namespace->getBucketName(), $this->location->getKey(), $this->data ?: ""];
     if (!$namespace->isDefaultType()) {
         $data[] = $namespace->getBucketType();
     }
     return $data;
 }
Example #2
0
 /**
  * @return \Riak\Client\Core\Message\Kv\GetRequest
  */
 private function createGetRequest()
 {
     $request = new GetRequest();
     $namespace = $this->location->getNamespace();
     $request->type = $namespace->getBucketType();
     $request->bucket = $namespace->getBucketName();
     $request->key = $this->location->getKey();
     foreach ($this->options as $name => $value) {
         $request->{$name} = $value;
     }
     return $request;
 }
Example #3
0
 /**
  * @return \Riak\Client\Core\Message\Kv\DeleteRequest
  */
 private function createDeleteRequest()
 {
     $request = new DeleteRequest();
     $namespace = $this->location->getNamespace();
     foreach ($this->options as $name => $value) {
         $request->{$name} = $value;
     }
     $request->key = $this->location->getKey();
     $request->type = $namespace->getBucketType();
     $request->bucket = $namespace->getBucketName();
     $request->vClock = $this->vClock ? $this->vClock->getValue() : null;
     return $request;
 }
Example #4
0
 /**
  * @return \Riak\Client\Core\Message\Kv\PutRequest
  */
 private function createPutRequest()
 {
     $request = new PutRequest();
     $riakObject = $this->getConvertedValue();
     $namespace = $this->location->getNamespace();
     $objectConverter = $this->config->getRiakObjectConverter();
     $vClockValue = $riakObject->getVClock() ? $riakObject->getVClock()->getValue() : null;
     foreach ($this->options as $name => $value) {
         $request->{$name} = $value;
     }
     $request->vClock = $vClockValue;
     $request->key = $this->location->getKey();
     $request->type = $namespace->getBucketType();
     $request->bucket = $namespace->getBucketName();
     $request->content = $objectConverter->convertToRiakContent($riakObject);
     return $request;
 }
Example #5
0
 /**
  * @param object                               $domainObject
  * @param \Riak\Client\Core\Query\RiakObject   $riakObject
  * @param \Riak\Client\Core\Query\RiakLocation $location
  */
 public function setDomainObjectValues($domainObject, RiakObject $riakObject, RiakLocation $location)
 {
     $className = get_class($domainObject);
     $metadata = $this->metadataReader->getMetadataFor($className);
     if ($keyField = $metadata->getRiakKeyField()) {
         $this->setDomainObjectProperty($domainObject, $keyField, $location->getKey());
     }
     if ($bucketNameField = $metadata->getRiakBucketNameField()) {
         $bucketName = $location->getNamespace() ? $location->getNamespace()->getBucketName() : null;
         $this->setDomainObjectProperty($domainObject, $bucketNameField, $bucketName);
     }
     if ($bucketTypeField = $metadata->getRiakBucketTypeField()) {
         $bucketName = $location->getNamespace() ? $location->getNamespace()->getBucketType() : null;
         $this->setDomainObjectProperty($domainObject, $bucketTypeField, $bucketName);
     }
     if ($vClockField = $metadata->getRiakVClockField()) {
         $this->setDomainObjectProperty($domainObject, $vClockField, $riakObject->getVClock());
     }
     if ($lastModifiedField = $metadata->getRiakLastModifiedField()) {
         $this->setDomainObjectProperty($domainObject, $lastModifiedField, $riakObject->getLastModified());
     }
     if ($contentTypeField = $metadata->getRiakContentTypeField()) {
         $this->setDomainObjectProperty($domainObject, $contentTypeField, $riakObject->getContentType());
     }
 }
Example #6
0
 public function testLocationAndLocation()
 {
     $namaspace1 = new RiakNamespace('type-1', 'bucket-1');
     $namaspace2 = new RiakNamespace('type-2', 'bucket-2');
     $location = new RiakLocation($namaspace1, 'key-1');
     $this->assertEquals('key-1', $location->getKey());
     $this->assertSame($namaspace1, $location->getNamespace());
     $this->assertEquals('type-1', $location->getNamespace()->getBucketType());
     $this->assertEquals('bucket-1', $location->getNamespace()->getBucketName());
     $location->setKey('key-2');
     $location->setNamespace($namaspace2);
     $this->assertEquals('key-2', $location->getKey());
     $this->assertSame($namaspace2, $location->getNamespace());
     $this->assertEquals('type-2', $location->getNamespace()->getBucketType());
     $this->assertEquals('bucket-2', $location->getNamespace()->getBucketName());
 }