You are here

protected function MongoDbProfilerStorage::getMongo in Zircon Profile 8.0

Same name and namespace in other branches
  1. 8 vendor/symfony/http-kernel/Profiler/MongoDbProfilerStorage.php \Symfony\Component\HttpKernel\Profiler\MongoDbProfilerStorage::getMongo()

Internal convenience method that returns the instance of the MongoDB Collection.

Return value

\MongoCollection

Throws

\RuntimeException

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

File

vendor/symfony/http-kernel/Profiler/MongoDbProfilerStorage.php, line 101

Class

MongoDbProfilerStorage

Namespace

Symfony\Component\HttpKernel\Profiler

Code

protected function getMongo() {
  if (null !== $this->mongo) {
    return $this->mongo;
  }
  if (!($parsedDsn = $this
    ->parseDsn($this->dsn))) {
    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@]host/database/collection"', $this->dsn));
  }
  list($server, $database, $collection) = $parsedDsn;
  $mongoClass = version_compare(phpversion('mongo'), '1.3.0', '<') ? '\\Mongo' : '\\MongoClient';
  $mongo = new $mongoClass($server);
  return $this->mongo = $mongo
    ->selectCollection($database, $collection);
}