Create an instance of the database cache driver.

@param  array $config
@return \Zilf\Cache\DatabaseStore
977835
protected function createDatabaseDriver(array $config)
    {
        $connection = $this->app['db']->connection(Arr::get($config, 'connection'));

        return $this->repository(
            new DatabaseStore(
                $connection, $config['table'], $this->getPrefix($config)
            )
        );
    }
1368858
public function createCommand($config = [])
    {
        $this->open();
        $config['db'] = $this;
        $command = new Command($config);

        return $command;
    }
876534
public function setHandler(array $config)
    {
        $connect = $config['connect'] ?? [];

        switch (strtolower($config['handler'])) {
            case 'redis':
                $class = Handler\Redis::class;
                $conn = Redis::client($connect);
                break;

            case 'simple':
            case 'simplecache':
                $class = Handler\SimpleCache::class;
                $conn = Cache::simple($connect);
                break;

            case 'cache':
                $class = Handler\Cache::class;
                $conn = Cache::pool($connect);
                break;

            case 'db':
                $class = Handler\Database::class;
                $conn = Database::pdo($connect);
                break;

            default:
                return;
        }

        $settings = $config['settings'] ?? [];
        if (!isset($settings['lifetime']) && isset($this->cookieParams['lifetime'])) {
            $settings['lifetime'] = $this->cookieParams['lifetime'];
        }

        $this->handler = new $class($conn, $settings);
    }
775175
protected function createCustomDriver(array $config)
    {
        $factory = is_callable($via = $config['via']) ? $via : $this->app->make($via);

        return $factory($config);
    }
473515
protected function createTokenRepository( array $config )
	{
		$key = Config::get( 'app.key' );

		if ( Str::startsWith( $key, 'base64:' ) )
			$key = base64_decode( substr( $key, 7 ) );

		$connection = isset( $config['connection'] ) ? $config['connection'] : null;

		return new DatabaseTokenRepository( DatabaseManager::i()->connection( $connection ), $config['table'], $key, $config['expire'] );
	}
1044685
public function connect(array $config)
    {
        $options = $this->options($config);

        // SQLite provides supported for "in-memory" databases, which exist only for
        // lifetime of the request. These are mainly for tests.
        if ($config['database'] == ':memory:') {
            return new \Pimf\Database('sqlite::memory:', null, null, $options);
        }

        return new \Pimf\Database('sqlite:' . $config['database'], null, null, $options);
    }
499144
public function createConnector(array $config)
    {
        if (!isset($config['driver'])) {
            throw new InvalidArgumentException('A driver must be specified.');
        }

        switch ($config['driver']) {
            case 'awss3':
                return new AwsS3Connector();
            case 'azure':
                return new AzureConnector();
            case 'dropbox':
                return new DropboxConnector();
            case 'ftp':
                return new FtpConnector();
            case 'gridfs':
                return new GridFSConnector();
            case 'local':
                return new LocalConnector();
            case 'null':
                return new NullConnector();
            case 'rackspace':
                return new RackspaceConnector();
            case 'sftp':
                return new SftpConnector();
            case 'webdav':
                return new WebDavConnector();
            case 'zip':
                return new ZipConnector();
        }

        throw new InvalidArgumentException("Unsupported driver [{$config['driver']}].");
    }
789659
public static function getInstance(array $config = array(), DriverInterface $driver = null)
    {
        static $instance = null;

        if (null === $instance) {
            $instance = new static();
        }

        if ($config) {
            $instance->config = $config;
        }

        if ($driver) {
            $instance->driver = $driver;
        }

        return $instance;
    }
22096
public static function instance($name = 'default', array $config = array())
    {
        if ( ! isset(self::$instances[$name])) {
            if (empty($config)) {
                // Load the configuration for this database
                $config = self::config($name);
            }

            self::$instances[$name] = new self($name, $config);
        }

        return self::$instances[$name];
    }
1270328
public function make(array $config): ProfileBuilder
    {
        $config = $this->getConfig($config);

        return $this->getProfileBuilder($config);
    }
380675
public function createConnector(array $config)
    {
        if (!isset($config['driver'])) {
            throw new Exception('A driver must be specified.');
        }

        switch ($config['driver']) {
            case 'mysql':
                return new MySqlConnector;
            case 'pgsql':
                return new PostgresConnector;
            case 'sqlite':
                return new SQLiteConnector;
            case 'sqlsrv':
                return new SqlServerConnector;
            case 'filesystem':
                return new FileSystemConnector;
        }
        throw new Exception("Unsupported driver [{$config['driver']}]");
    }
1018981
public static function simple(array $config = []): CacheInterface
    {
        [$hash, $config] = static::getKey($config, 'cache.simple');

        if (isset(static::$pool[$hash])) {
            return static::$pool[$hash];
        }

        if (isset($config['drivers'])) {
            $drivers = $config['drivers'];
            if (\count($drivers) > 1) {
                return static::$pool[$hash] = new Chain($config);
            }

            unset($config['drivers']);

            $driver = \key($drivers);
            $config += $drivers[$driver];
        } else {
            $driver = $config['driver'] ?? 'void';
            unset($config['driver']);
        }

        switch ($driver) {
            case 'array':
            case 'zend':
                $driver = \ucfirst($driver) . 'Data';
                break;
            case 'apc':
                $driver = 'Apcu';
                break;
            default:
                $driver = \ucfirst($driver);
        }

        $class = 'Hail\\Cache\\Simple\\' . $driver;

        return static::$pool[$hash] = new $class($config);
    }
341189
public static function getDbInstance(Config $config) {
            $handle = self::getDbHandle($config);
            if (!isset(self::$pool[ $handle ])) {
                self::$pool[ $handle ] = new DB($config);
            }

            return self::$pool[ $handle ];
        }
759141
protected function createRedisDriver( array $config )
	{
		$redis = Framework::get( 'redis' );

		$connection = Arr::get( $config, 'connection', 'default' );

		return new RedisStore( $redis, $this->getPrefix( $config ), $connection );
	}
698713
public function createConnection($config)
    {
        $driver = $this->driver_manager->driver(array_get($config, 'driver', ''));

        if (!($driver instanceof \Doctrine\DBAL\Driver)) {
            $driver = $this->driver_manager->driver();
        }

        $params = $config;
        $params['host'] = array_get($params, 'host', array_get($config, 'server'));
        $params['user'] = array_get($params, 'user', array_get($config, 'username'));
        if (!isset($params['driverOptions'])) {
            $params['driverOptions'] = [];
        }
        if (defined('PDO::MYSQL_ATTR_MULTI_STATEMENTS')) {
            $params['driverOptions'][\PDO::MYSQL_ATTR_MULTI_STATEMENTS] = false;
        }
        $params['wrapperClass'] = array_get($config, 'wrapperClass', '\Concrete\Core\Database\Connection\Connection');
        unset($params['driver']);

        $wrapperClass = 'Doctrine\DBAL\Connection';
        if (isset($params['wrapperClass'])) {
            if (is_subclass_of($params['wrapperClass'], $wrapperClass)) {
                $wrapperClass = $params['wrapperClass'];
            } else {
                throw DBALException::invalidWrapperClass($params['wrapperClass']);
            }
        }

        $connection =  new $wrapperClass($params, $driver);
        $connection->getDatabasePlatform()->registerDoctrineTypeMapping('json', 'json_array');
        return $connection;
    }
413855
protected function createRedisDriver(array $config)
    {
        $connection = Arr::get($config, 'connection');

        // Create a Redis Database instance.
        $redis = $this->app->make('redis');

        return new RedisBroadcaster($this->app, $redis, $connection);
    }
1070909
public static function create(
        array $config,
        CacheInterface $cache = null,
        Request $request = null,
        StorageInterface $storageDriver = null
    ) {
        if (empty($cache)) {
            $cache = new ArrayCache();
        }
        if (empty($request)) {
            $request = Request::createFromGlobals();
        }
        if (empty($storageDriver)) {
            $storageDriver = new FileStorage(__DIR__);
        }

        $driverManager = new DriverManager($config, new Curl());
        $driver = $driverManager->getMatchingDriver($request);

        return new BotMan($cache, $driver, $config, $storageDriver);
    }