示例#1
0
 /**
  * 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;
     });
 }
示例#2
0
 /**
  * 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;
 }
示例#3
0
 public static function resetMongo()
 {
     MongoDbConnector::getInstance()->getDatabase("yiid")->drop();
     MongoDbConnector::getInstance()->getDatabase("yiid_stats")->drop();
 }
示例#4
0
 /**
  *
  */
 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');
 }
示例#5
0
 public static function getMongoCollection()
 {
     return MongoDbConnector::getInstance()->getCollection(sfConfig::get('app_mongodb_database_name_stats'), self::MONGO_COLLECTION_NAME);
 }
示例#6
0
 public static function getMongoCollection($pCollection)
 {
     return MongoDbConnector::getInstance()->getCollection(sfConfig::get('app_mongodb_database_name_stats'), $pCollection);
 }