/** * Register MongoDbConnector within the application * * @return void */ public function registerConnector() { $connectionString = $this->buildConnectionString(); $connection = new MongoDbConnector(); $connection->getConnection($connectionString); $this->app['NeoMongoConnector'] = $this->app->share(function ($app) use($connection) { return $connection; }); }
/** * singleton logic, connect to mongodb based on host parameter in app.yml * * @return self */ public static function getInstance() { if (null === self::$aInstance) { self::$aInstance = new MongoDbConnector(); self::$aMongoConn = new Mongo(sfConfig::get('app_mongodb_host')); } return self::$aInstance; }
public static function resetMongo() { MongoDbConnector::getInstance()->getDatabase("yiid")->drop(); MongoDbConnector::getInstance()->getDatabase("yiid_stats")->drop(); }
/** * */ protected function executeDbTasks($arguments = array(), $options = array()) { $this->logSection('yiid', 'run db tasks'); // new options array $opts = array(); $env = $opts['env'] = $options['env']; // new arguments array $args = array(); if ($options['no-confirmation']) { $args[] = '--no-confirmation'; } // generate arguments array if ($env == 'dev' || $env == 'staging') { // add arguments for the "dev" or "staging" environment $args[] = '--all'; // check if "confirmation" is enabled $args[] = '--and-load'; } elseif ($env == 'prod') { // add arguments for the "prod" environment $args[] = '--all-classes'; // $args[] = '--and-migrate'; } else { throw new sfException(sprintf('Module "%s" does not exist.', $env)); } // run doctrine build task $this->runTask('doctrine:build', $args, array('env' => $opts['env'])); // clean up models folder $this->runTask('doctrine:clean', array("--no-confirmation")); // initialize mongo objects if ($env == 'dev' || $env == 'staging') { if ($options['no-confirmation'] || "y" == $this->ask("Mongo auf dem " . $env . '-System plattmachen? (host: ' . sfConfig::get('app_mongodb_host') . ' collection: ' . sfConfig::get('app_mongodb_database_name') . ") (y/N)")) { $this->logSection('mongo tasks', 'i am the mongo killer! now killing:'); $this->logSection('mongo tasks', '(host: ' . sfConfig::get('app_mongodb_host') . ' collection: ' . sfConfig::get('app_mongodb_database_name') . ')'); MongoDbConnector::getInstance()->getDatabase(sfConfig::get('app_mongodb_database_name'))->drop(); $this->logSection('mongo tasks', ' (host: ' . sfConfig::get('app_mongodb_host') . ' collection: ' . sfConfig::get('app_mongodb_database_name_stats') . ')'); MongoDbConnector::getInstance()->getDatabase(sfConfig::get('app_mongodb_database_name_stats'))->drop(); $this->runTask('yiid:activity-testdata', array(), array('env' => $opts['env'])); //$this->getFilesystem()->execute("php data/fixtures/initializeMongoObjects.php"); } } $this->runTask('cc'); }
public static function getMongoCollection() { return MongoDbConnector::getInstance()->getCollection(sfConfig::get('app_mongodb_database_name_stats'), self::MONGO_COLLECTION_NAME); }
public static function getMongoCollection($pCollection) { return MongoDbConnector::getInstance()->getCollection(sfConfig::get('app_mongodb_database_name_stats'), $pCollection); }