Ejemplo n.º 1
0
 /**
  * Converts a single mongo document into the appropriate Morph_Object
  *
  * @param array $item
  * @return Morph_Object
  */
 private function createObject(array $item)
 {
     $class = \get_class($this->type);
     $object = new $class();
     $object->__setData($item, Enum::STATE_CLEAN)->collection($this->type->collection());
     return $object;
 }
Ejemplo n.º 2
0
 /**
  * Generates an object reference for Has* properties
  *
  * @param $object
  * @return array
  */
 public static function objectReference(Morph_Object $object)
 {
     $reference = array('$ref' => $object->collection(), '$id' => $object->id());
     //causes a fatal error in PHP at present. Will try again later
     //$reference = MorphDBRef::create($object->collection(), $object->id());
     return $reference;
 }
Ejemplo n.º 3
0
 /**
  * Deletes the object passed in from the database
  * @param Morph_Object $object
  * @return boolean
  */
 public function delete(Morph_Object $object)
 {
     $query = array('_id' => $object->id());
     return $this->Db->selectCollection($object->collection())->remove($query, true);
 }