public static function connect($databaseConfig, $label = 'default')
    {
        // This is used by the "testsession" module to test up a test session using an alternative name
        if ($name = self::get_alternative_database_name()) {
            $databaseConfig['database'] = $name;
        }

        if (!isset($databaseConfig['type']) || empty($databaseConfig['type'])) {
            throw new InvalidArgumentException("DB::connect: Not passed a valid database config");
        }

        self::$connection_attempted = true;

        $dbClass = $databaseConfig['type'];

        // Using Injector->create allows us to use registered configurations
        // which may or may not map to explicit objects
        $conn = Injector::inst()->create($dbClass);
        self::set_conn($conn, $label);
        $conn->connect($databaseConfig);

        return $conn;
    }