protected function MongoDbProfilerStorage::getMongo

Internal convenience method that returns the instance of the MongoDB Collection

Return value

\MongoCollection

1 call to MongoDbProfilerStorage::getMongo()
DummyMongoDbProfilerStorage::getMongo in drupal/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/Profiler/MongoDbProfilerStorageTest.php
Internal convenience method that returns the instance of the MongoDB Collection
1 method overrides MongoDbProfilerStorage::getMongo()
DummyMongoDbProfilerStorage::getMongo in drupal/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/Profiler/MongoDbProfilerStorageTest.php
Internal convenience method that returns the instance of the MongoDB Collection

File

drupal/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Profiler/MongoDbProfilerStorage.php, line 113

Class

MongoDbProfilerStorage

Namespace

Symfony\Component\HttpKernel\Profiler

Code

protected function getMongo() {
  if ($this->mongo === null) {
    if (preg_match('#^(mongodb://.*)/(.*)/(.*)$#', $this->dsn, $matches)) {
      $mongo = new \Mongo($matches[1] . (!empty($matches[2]) ? '/' . $matches[2] : ''));
      $database = $matches[2];
      $collection = $matches[3];
      $this->mongo = $mongo
        ->selectCollection($database, $collection);
    }
    else {
      throw new \RuntimeException(sprintf('Please check your configuration. You are trying to use MongoDB with an invalid dsn "%s". The expected format is "mongodb://user:pass@location/database/collection"', $this->dsn));
    }
  }
  return $this->mongo;
}