Exemplo n.º 1
0
 /**
  * @param $identifier
  * @return BlogPostInterface|null
  */
 public function getBlogPost($identifier)
 {
     $getOutput = $this->bucket->get($identifier);
     if ($getOutput->hasObject()) {
         $obj = $getOutput->getFirstObject();
         $content = $obj->getContent();
         if (!$obj->isDeleted() && isset($content)) {
             return RiakBlogPost::instanceFromJsonString($content);
         }
     }
     return null;
 }
Exemplo n.º 2
0
 /**
  * {@inheritdoc}
  */
 protected function doContains($id)
 {
     try {
         // We only need the HEAD, not the entire object
         $input = new Input\GetInput();
         $input->setReturnHead(true);
         $response = $this->bucket->get($id, $input);
         // No objects found
         if (!$response->hasObject()) {
             return false;
         }
         $object = $response->getFirstObject();
         // Check for expired object
         if ($this->isExpired($object)) {
             $this->bucket->delete($object);
             return false;
         }
         return true;
     } catch (Exception\RiakException $e) {
         // Do nothing
     }
     return false;
 }
Exemplo n.º 3
0
 /**
  * {@inheritdoc}
  */
 protected function doContains($id)
 {
     try {
         $input = new Input\GetInput();
         $input->setReturnHead(true);
         $response = $this->bucket->get(urlencode($id), $input);
         // No objects found
         if (!$response->hasObject()) {
             return false;
         }
         $object = $response->getFirstObject();
         if ($this->isExpired($object)) {
             return false;
         }
         return true;
     } catch (Exception\RiakException $e) {
         // Do nothing
     }
     return false;
 }