protected function registerMongator()
 {
     $this->app['mongator'] = $this->app->share(function ($app) {
         $mongator = new Mongator($app['mongator.metadata'], $this->getLogger());
         $mongator->setFieldsCache($app['mongator.cache.fields']);
         $mongator->setDataCache($app['mongator.cache.data']);
         $mongator->setConnection($app['config']['mongator::connection_name'], $app['mandango.connection']);
         $mongator->setDefaultConnectionName($app['config']['mongator::connection_name']);
         return $mongator;
     });
 }
 public function register(Container $app)
 {
     $app['mongator'] = function ($app) {
         $mongator = new Mongator($app['mongator.metadata'], $app['mongator.logger']);
         $mongator->setFieldsCache($app['mongator.cache.fields']);
         $mongator->setDataCache($app['mongator.cache.data']);
         $mongator->setConnection($app['mongator.connection.name'], $app['mandango.connection']);
         $mongator->setDefaultConnectionName($app['mongator.connection.name']);
         return $mongator;
     };
     $app['mongator.metadata'] = function ($app) {
         if (!class_exists($app['mongator.metadata.class'])) {
             throw new \LogicException('You must register a valid "mongator.metadata.class" to this provider, maybe you forget to generate your models?');
         }
         return new $app['mongator.metadata.class']();
     };
     $app['mandango.connection'] = function ($app) {
         if (!$app['mongator.connection.dsn']) {
             throw new \LogicException('You must register "mongator.connection.dsn" to this provider');
         }
         if (!$app['mongator.connection.database']) {
             throw new \LogicException('You must register "mongator.connection.database" to this provider');
         }
         return new Connection($app['mongator.connection.dsn'], $app['mongator.connection.database']);
     };
     $app['mongator.cache.fields'] = function ($app) {
         return new ArrayCache();
     };
     $app['mongator.cache.data'] = function ($app) {
         return new ArrayCache();
     };
     $app['mongator.metadata.class'] = null;
     $app['mongator.logger'] = null;
     $app['mongator.connection.name'] = 'default';
     $app['mongator.connection.dsn'] = 'mongodb://localhost:27017';
     $app['mongator.connection.database'] = null;
     $app['mongator.classes.config'] = array();
     $app['mongator.classes.yaml.path'] = null;
 }
Exemple #3
0
 public function testGetDataCache()
 {
     $mongator = new Mongator($this->metadataFactory);
     $cache = new ArrayCache();
     $mongator->setDataCache($cache);
     $this->assertSame($cache, $mongator->getDataCache());
 }