|
|
@@ -51,19 +51,23 @@ class Mooses_AbstractMongo extends Mooses_Mongodb_Mongo_Document {
|
|
|
return self::$_instance;
|
|
|
}
|
|
|
|
|
|
- protected function _retrieveTableName() {
|
|
|
+ protected static function ___retrieveTableName(){
|
|
|
$_return = array();
|
|
|
- $annotations = new ReflectionClass($this);
|
|
|
+ $annotations = new ReflectionClass(get_called_class());
|
|
|
$_tableSuffix = NULL;
|
|
|
$_tablePrefix = "re_";
|
|
|
- $_databaseAnnotated = $this->_parseDocComment($annotations->getDocComment(), "@Db");
|
|
|
- $_collectionAnnotated = $this->_parseDocComment($annotations->getDocComment(), "@Collection");
|
|
|
+ $_databaseAnnotated = self::_parseDocComment($annotations->getDocComment(), "@Db");
|
|
|
+ $_collectionAnnotated = self::_parseDocComment($annotations->getDocComment(), "@Collection");
|
|
|
$_return['collection'] = (stristr($_collectionAnnotated, $_tableSuffix)) ? $_collectionAnnotated : $_tablePrefix . $_collectionAnnotated . $_tableSuffix;
|
|
|
$_return['db'] = $_databaseAnnotated;
|
|
|
return $_return;
|
|
|
}
|
|
|
|
|
|
- private function _parseDocComment($str, $tag = '') {
|
|
|
+ protected function _retrieveTableName() {
|
|
|
+ return self::___retrieveTableName();
|
|
|
+ }
|
|
|
+
|
|
|
+ private static function _parseDocComment($str, $tag = ''){
|
|
|
if (empty($tag)) {
|
|
|
return $str;
|
|
|
}
|
|
|
@@ -72,7 +76,6 @@ class Mooses_AbstractMongo extends Mooses_Mongodb_Mongo_Document {
|
|
|
if (isset($matches[1])) {
|
|
|
return trim($matches[1]);
|
|
|
}
|
|
|
-
|
|
|
return '';
|
|
|
}
|
|
|
|
|
|
@@ -140,7 +143,7 @@ class Mooses_AbstractMongo extends Mooses_Mongodb_Mongo_Document {
|
|
|
public static function __callStatic($name, $arguments)
|
|
|
{
|
|
|
if(get_called_class() != get_class(self::$_instance)){
|
|
|
- $_mongoInformations = $this->_retrieveTableName();
|
|
|
+ $_mongoInformations = self::_retrieveTableName();
|
|
|
self::$_db = $_mongoInformations['db'];
|
|
|
static::$_db = $_mongoInformations['db'];
|
|
|
self::$_collection = $_mongoInformations['collection'];
|