/** * Get document instance * * @return \Sokil\Mongo\Document */ public function getDocument() { $data = $this->toArray(); // restore document id $data['_id'] = $data['__documentId__']; // unset meta fields unset($data['__date__'], $data['__documentId__']); return $this->baseCollection->hydrate($data); }
public function current() { $mongoDocument = $this->getCursor()->current(); if (!$mongoDocument) { return null; } if ($this->resultAsArray) { return $mongoDocument; } return $this->collection->hydrate($mongoDocument, $this->isDocumentPoolUsed()); }
/** * @expectedException \Sokil\Mongo\Exception * @expectedExceptionMessage Document must be stored and has _id key */ public function testGetStoredDocumentInstanceFromArray_DocumentNotStored() { $document = $this->collection->hydrate(array('param' => 'value')); $this->assertTrue($document->isStored()); }