Mongolid\Connection\Pool::addConnection PHP Method

addConnection() public method

Adds a new connection to the pool.
public addConnection ( Connection $conn ) : boolean
$conn Connection The actual connection that will be added to the pool.
return boolean Success
    public function addConnection(Connection $conn)
    {
        $this->connections->push($conn);
        return true;
    }

Usage Example

 /**
  * Register MongoDbConnector within the application.
  *
  * @return void
  */
 public function registerConnector()
 {
     $config = $this->app->make('config');
     MongolidIoc::setContainer($this->app);
     $connectionString = $this->buildConnectionString();
     $connection = new Connection($connectionString);
     $pool = new Pool();
     $eventService = new EventTriggerService();
     $eventService->registerEventDispatcher($this->app->make(LaravelEventTrigger::class));
     $pool->addConnection($connection);
     $this->app->instance(Pool::class, $pool);
     $this->app->instance(EventTriggerService::class, $eventService);
     $this->app->bind(CacheComponentInterface::class, function ($app) {
         return new LaravelCacheComponent($app[CacheRepository::class], $app[Serializer::class]);
     });
     $connection->defaultDatabase = $config->get('database.mongodb.default.database', 'mongolid');
 }
All Usage Examples Of Mongolid\Connection\Pool::addConnection