public function getFileById($id)
{
if ($id instanceof \MongoId) {
$file = $this->getMongoCollection()->findOne(array('_id' => $id));
} else {
try {
$file = $this->getMongoCollection()->findOne(array('_id' => new \MongoId($id)));
} catch (\MongoException $e) {
$file = $this->getMongoCollection()->findOne(array('_id' => $id));
}
}
if (!$file) {
return null;
}
$fileClassName = $this->getFileClassName($file);
return new $fileClassName($this, $file);
}