Ejemplo n.º 1
0
 /**
  * @return DocumentManager
  */
 private function connect()
 {
     $config = new Configuration();
     $config->setProxyDir($this->app['cache']['doctrine'] . '/mongodb/proxy');
     $config->setProxyNamespace('Proxies');
     $config->setHydratorDir($this->app['cache']['doctrine'] . '/mongodb/hydrators');
     $config->setHydratorNamespace('Hydrators');
     $anno = [];
     foreach ($this->config['modules'] as $app) {
         $dir = $this->app['BASE_DIR'] . $this->app['Modules'] . $app . '/Document';
         if (file_exists($dir)) {
             $anno[] = $dir;
         }
     }
     $driverImpl = $config->newDefaultAnnotationDriver($anno);
     $config->setMetadataDriverImpl($driverImpl);
     $config->setDefaultDB($this->config['database']['name']);
     $config->setDefaultCommitOptions(array('safe' => true, 'fsync' => true));
     return DocumentManager::create(new Connection($this->config['database']['host']), $config);
 }