Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

cleaning up public api

  • Loading branch information...
commit 5c36d63fb119b96d769676b018506f1950d16136 1 parent 7713f90
Jonthan Moss authored
Showing with 12 additions and 68 deletions.
  1. +7 −23 src/morph/Object.php
  2. +5 −45 src/morph/Storage.php
View
30 src/morph/Object.php
@@ -209,6 +209,9 @@ public function save(array $options = array())
/**
* Attempts to load the current object with data from the document id specified
*
+ * By default Morph sets the id to be an instance of MongoId(). When searching you need
+ * to ensure you do the same by wrapping your id string in a MongoId object
+ *
* @param mixed $id
* @return Morph_Object
*/
@@ -216,20 +219,12 @@ public function loadById($id)
{
return Storage::instance()->fetchById($this, $id);
}
-
- /**
- * Attempts to load the current object with data from the document id specified
- *
- * @param mixed $id
- * @return Morph_Object
- */
- public function loadByObjectId($id)
- {
- return Storage::instance()->fetchByObjectId($this, $id);
- }
/**
* Fetch multiple objects by their ids
+ *
+ * By default Morph sets the id to be an instance of MongoId(). When searching you need
+ * to ensure you do the same by wrapping your id string in a MongoId object
*
* @param array $ids
* @return Morph_Iterator
@@ -238,18 +233,7 @@ public function findByIds(array $ids)
{
return Storage::instance()->fetchByIds($this, $ids);
}
-
- /**
- * Fetch multiple objects by their ids
- *
- * @param array $ids
- * @return Morph_Iterator
- */
- public function findByObjectIds(array $ids)
- {
- return Storage::instance()->fetchByObjectIds($this, $ids);
- }
-
+
/**
* Find objects by query
*
View
50 src/morph/Storage.php
@@ -95,9 +95,8 @@ public function getDatabase()
* Retrieves the contents of the specified $id
* and assigns them into $object
*
- * This shoudld be used if the _id is not necessarily a ObjectId()
- * (or the php version, MongoId() ). You can always just wrap the id string
- * in new \MongoId() as well
+ * By default Morph sets the id to be an instance of MongoId(). When searching you need
+ * to ensure you do the same by wrapping your id string in a MongoId object
*
* @param Morph\\Object $object
* @param mixed $id
@@ -109,28 +108,12 @@ public function fetchById(Object $object, $id)
$data = $this->db->selectCollection($object->collection())->findOne($query);
return $this->setData($object, $data);
}
-
- /**
- * Retrieves the contents of the specified $id
- * and assigns them into $object
- * This function is meant for if the _id is a ObjectId (the default)
- *
- * @param Morph\\Object $object
- * @param mixed $id
- * @return Morph\\Object
- */
- public function fetchByObjectId(Object $object, $id)
- {
- if (is_string($id)) {
- $id = new \MongoId($id);
- }
- $query = array('_id' => $id);
- $data = $this->db->selectCollection($object->collection())->findOne($query);
- return $this->setData($object, $data);
- }
/**
* Returns all objects with an _id in $ids
+ *
+ * By default Morph sets the id to be an instance of MongoId(). When searching you need
+ * to ensure you do the same by wrapping your id string in a MongoId object
*
* @param Morph\\Object $object
* @param array $Ids
@@ -142,29 +125,6 @@ public function fetchByIds(Object $object, array $ids)
$query->property('_id')->in($ids);
return $this->findByQuery($object, $query);
}
-
- /**
- * Returns all objects with an _id in $ids
- *
- * @param Morph\\Object $object
- * @param array $Ids
- * @return Morph\\Iterator
- */
- public function fetchObjectByIds(Object $object, array $ids)
- {
- $query = new Query();
- $wrappedIds = array();
- foreach ($ids as $id) {
- if (is_string($id)) {
- $wrappedIds[] = new \MongoId($id);
- } else {
- $wrappedIds[] = $id;
- }
- }
-
- $query->property('_id')->in($ids);
- return $this->findByQuery($object, $query);
- }
/**
* Retrieves the contents of the specified $dbRef
Please sign in to comment.
Something went wrong with that request. Please try again.