public static function getDocumentInstance($id) { if (self::isCached($id)) { return self::getCachedObj($id); } else { try { $genericDocument = DocumentPeer::retrieveByPk($id); if (!$genericDocument) { return null; } $model = $genericDocument->getDocumentModel(); //echo "NOT CACHED ".$model; $classPeer = $model . 'Peer'; $c = new Criteria(); $c->add(constant($classPeer . '::ID'), $id); $document = call_user_func(array($classPeer, 'doSelectOne'), $c); return $document; } catch (Exception $e) { throw $e; } } }