Exemplo n.º 1
0
 public function __construct(Epic_Mongo_Document $document)
 {
     $this->_document = $document;
     $this->_properties = $document->getPropertyKeys();
     $this->_position = current($this->_properties);
     reset($this->_properties);
 }
Exemplo n.º 2
0
 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);
 }
Exemplo n.º 3
0
 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);
 }
Exemplo n.º 4
0
 /**
  * @expectedException Epic_Mongo_Exception
  */
 public function testCreateReferenceException2()
 {
     $doc = new Epic_Mongo_Document(array(), array('collection' => 'test_document', 'pathToDocument' => 'test'));
     $doc->createReference();
 }