コード例 #1
0
 /**
  * @param \Riak\Client\Core\Query\RiakObject   $riakObject
  * @param object                               $domainObject
  * @param \Riak\Client\Core\Query\RiakLocation $location
  */
 public function setRiakObjectValues(RiakObject $riakObject, $domainObject, RiakLocation $location)
 {
     $className = get_class($domainObject);
     $metadata = $this->metadataReader->getMetadataFor($className);
     if ($vClockField = $metadata->getRiakVClockField()) {
         $riakObject->setVClock($this->getDomainObjectProperty($domainObject, $vClockField));
     }
     if ($lastModifiedField = $metadata->getRiakLastModifiedField()) {
         $riakObject->setLastModified($this->getDomainObjectProperty($domainObject, $lastModifiedField));
     }
     if ($contentTypeField = $metadata->getRiakContentTypeField()) {
         $riakObject->setContentType($this->getDomainObjectProperty($domainObject, $contentTypeField));
     }
 }
コード例 #2
0
 public function testHidrateDomainObject()
 {
     $riakObject = new RiakObject();
     $domainObject = new SimpleObject();
     $vClock = new VClock('vclock-hash');
     $namespace = new RiakNamespace('type', 'bucket');
     $location = new RiakLocation($namespace, 'riak-key');
     $riakObject->setVClock($vClock);
     $riakObject->setContentType('application/json');
     $riakObject->setLastModified('Sat, 01 Jan 2015 01:01:01 GMT');
     $this->instance->setDomainObjectValues($domainObject, $riakObject, $location);
     $this->assertEquals('Sat, 01 Jan 2015 01:01:01 GMT', $domainObject->getRiakLastModified());
     $this->assertEquals('application/json', $domainObject->getRiakContentType());
     $this->assertEquals('bucket', $domainObject->getRiakBucketName());
     $this->assertEquals('type', $domainObject->getRiakBucketType());
     $this->assertEquals('riak-key', $domainObject->getRiakKey());
     $this->assertEquals($vClock, $domainObject->getRiakVClock());
 }
コード例 #3
0
 /**
  * @param \Riak\Client\Core\Message\Kv\Content $content
  * @param \Riak\Client\Core\Query\VClock       $vClock
  *
  * @return \Riak\Client\Core\Query\RiakObject
  */
 private function convertToRiakObject(Content $content, VClock $vClock)
 {
     $object = new RiakObject();
     $object->setVClock($vClock);
     $object->setVtag($content->vtag);
     $object->setValue($content->value);
     $object->setContentType($content->contentType);
     $object->setIsDeleted((bool) $content->deleted);
     $object->setLastModified($content->lastModified);
     if ($content->indexes) {
         $object->setIndexes($this->createRiakIndexList($content->indexes));
     }
     if ($content->metas) {
         $object->setUserMeta(new RiakUsermeta($content->metas));
     }
     if ($content->links) {
         $object->setLinks($this->createRiakLinkList($content->links));
     }
     return $object;
 }