public function __construct(Epic_Mongo_Document $document) { $this->_document = $document; $this->_properties = $document->getPropertyKeys(); $this->_position = current($this->_properties); reset($this->_properties); }
public function save($wholeDocument = false) { if ($this->_sequenceKey) { if (!$this->id) { $this->id = $this->getNextSequence($this->_sequenceKey); } } else { throw new Epic_Mongo_Exception("In order to extend Epic_Mongo_Document_Sequenced, your Document Class needs a protected _sequenceKey value specifying the key the sequence will be stored as."); } return parent::save($wholeDocument); }
public function setProperty($key, $value) { $new = is_null($key); if (!$new && !is_numeric($key)) { throw new Epic_Mongo_Exception('DocumentSets must only contain numeric keys'); } if (!(is_null($value) || $value instanceof Epic_Mongo_Document)) { throw new Epic_Mongo_Exception('DocumentSets must only contain documents'); } if ($new) { $keys = $this->getPropertyKeys(); if (empty($keys)) { $key = 0; } else { $key = max($keys) + 1; } } return parent::setProperty($key, $value); }
/** * @expectedException Epic_Mongo_Exception */ public function testCreateReferenceException2() { $doc = new Epic_Mongo_Document(array(), array('collection' => 'test_document', 'pathToDocument' => 'test')); $doc->createReference(); }