/** * @param mixed $model * @param string $id * @throws \Exception */ public function read($model, $id) { CodeGuard::checkTypeAndThrow($id, 'string'); $data = $this->_collection->findOne(array("_id" => self::mongoID($id))); if ($data === NULL) { $collection = (string) $this->_collection; throw new \Exception("Could not find id '{$id}' in '{$collection}'"); } try { MongoDecoder::decode($model, $data, $id); } catch (\Exception $ex) { CodeGuard::exception("Exception thrown while decoding '{$id}'", $ex->getCode(), $ex); } }