src/MongolidServiceProvider.php
public function registerConnector()
    {
        MongolidIoc::setContainer($this->app);

        $this->app->singleton(
            Pool::class,
            function ($app) {
                $config = $app['config']->get('database.mongodb.default') ?? [];
                $connectionString = $this->buildConnectionString($config);
                $options = $config['options'] ?? [];
                $driverOptions = $config['driver_options'] ?? [];

                $connection = new Connection($connectionString, $options, $driverOptions);
                $connection->defaultDatabase = $config['database'] ?? 'mongolid';

                $pool = new Pool();
                $pool->addConnection($connection);

                return $pool;
            }
        );
        $this->app->singleton(
            EventTriggerService::class,
            function ($app) {
                $eventService = new EventTriggerService();
                $eventService->registerEventDispatcher($app->make(LaravelEventTrigger::class));

                return $eventService;
            }
        );
        $this->app->singleton(
            CacheComponentInterface::class,
            function ($app) {
                return new LaravelCacheComponent($app[CacheRepository::class]);
            }
        );
    }
public function registerConnector()
    {
        MongolidIoc::setContainer($this->app);

        $this->app->singleton(
            Pool::class,
            function ($app) {
                $config = $app['config']->get('database.mongodb.default') ?? [];
                $connectionString = $this->buildConnectionString($config);
                $options = $config['options'] ?? [];
                $driverOptions = $config['driver_options'] ?? [];

                $connection = new Connection($connectionString, $options, $driverOptions);
                $connection->defaultDatabase = $config['database'] ?? 'mongolid';

                $pool = new Pool();
                $pool->addConnection($connection);

                return $pool;
            }
        );
        $this->app->singleton(
            EventTriggerService::class,
            function ($app) {
                $eventService = new EventTriggerService();
                $eventService->registerEventDispatcher($app->make(LaravelEventTrigger::class));

                return $eventService;
            }
        );
        $this->app->singleton(
            CacheComponentInterface::class,
            function ($app) {
                return new LaravelCacheComponent($app[CacheRepository::class]);
            }
        );
    }
public function registerConnector ( ) { MongolidIoc :: setContainer ( $ this -> app ) ; $ this -> app -> singleton ( Pool :: class , function ( $ app ) { $ config = $ app [ 'config' ] -> get ( 'database.mongodb.default' ) ?? [ ] ; $ connectionString = $ this -> buildConnectionString ( $ config ) ; $ options = $ config [ 'options' ] ?? [ ] ; $ driverOptions = $ config [ 'driver_options' ] ?? [ ] ; $ connection = new Connection ( $ connectionString , $ options , $ driverOptions ) ; $ connection -> defaultDatabase = $ config [ 'database' ] ?? 'mongolid' ; $ pool = new Pool ( ) ; $ pool -> addConnection ( $ connection ) ; return $ pool ; } ) ; $ this -> app -> singleton ( EventTriggerService :: class , function ( $ app ) { $ eventService = new EventTriggerService ( ) ; $ eventService -> registerEventDispatcher ( $ app -> make ( LaravelEventTrigger :: class ) ) ; return $ eventService ; } ) ; $ this -> app -> singleton ( CacheComponentInterface :: class , function ( $ app ) { return new LaravelCacheComponent ( $ app [ CacheRepository :: class ] ) ; } ) ; }
Register MongoDbConnector within the application.
Register MongoDbConnector within the application .