Пример #1
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());
     }
 }
Пример #2
0
 /**
  * @param \Riak\Client\Core\Query\RiakObject $riakObject
  *
  * @return array
  */
 public function convertToRiakContent(RiakObject $riakObject)
 {
     $content = new Content();
     $metas = $riakObject->getUserMeta();
     $indexes = $riakObject->getIndexes();
     $links = $riakObject->getLinks();
     $content->contentType = $riakObject->getContentType() ?: RiakObject::DEFAULT_CONTENT_TYPE;
     $content->lastModified = $riakObject->getLastModified();
     $content->isDeleted = $riakObject->getIsDeleted();
     $content->value = $riakObject->getValue();
     $content->vtag = $riakObject->getVtag();
     $content->indexes = [];
     $content->metas = [];
     if ($indexes != null) {
         $content->indexes = $indexes->toFullNameArray();
     }
     if ($metas != null) {
         $content->metas = $metas->toArray();
     }
     if ($links != null) {
         $content->links = $links->toArray();
     }
     return $content;
 }