Factory a HTTPPubSubAdapter.

@param array $config

@return HTTPPubSubAdapter
180118
protected function makeHTTPAdapter(array $config)
    {
        $client = $this->container->make('pubsub.http.client');
        $adapter = $this->make(
            $config['subscribe_connection_config']['driver'],
            $config['subscribe_connection_config']
        );
        return new HTTPPubSubAdapter($client, $config['uri'], $adapter);
    }
865711
public function connect(array $config)
    {
        $auth = $this->getAuth($config);
        $client = $this->getClient($auth);

        return $this->getAdapter($client);
    }
1344182
public function createS3Driver(array $config)
	{
		$s3Config = array_only($config, ['key', 'region', 'secret', 'signature', 'base_url']);

		return $this->adapt(
			new Flysystem(new S3Adapter(S3Client::factory($s3Config), $config['bucket']))
		);
	}
256514
public static function factory($config = array()) {
        $defaults = array(
            'base_url' => self::API_URL,
            'version' => 'v2.1',
            'command.params' => array(
                'command.on_complete' => function($command) {
                    $response = $command->getResult();

                    // We don't need the meta blocks
                    unset($response['meta']);

                    // If we're down to a single element (events, talks etc)
                    // return only this element
                    if (count($response) == 1) {
                        $command->setResult(reset($response));
                    }
                }
            )
        );

        $required = array(
            'base_url',
            'version',
        );

        $config = Collection::fromConfig($config, $defaults, $required);

        $client = new self($config->get('base_url'), $config);

        // Attach a service description to the client
        $description = ServiceDescription::factory(__DIR__ . '/client.json');
        $client->setDescription($description);

        return $client;
    }
352814
public function bootstrap($config = array())
    {
        $config = new KObjectConfigJson($config);
        $config->append(array(
            'debug' => JFactory::getApplication()->getCfg('debug')
        ));

        $html = '';

        if ($this->getTemplate()->decorator() === 'joomla')
        {
            $config->append([
                'css' => file_exists(JPATH_THEMES.'/'.JFactory::getApplication()->getTemplate().'/enable-koowa-bootstrap.txt')
            ]);

            if ($config->javascript && !static::isLoaded('bootstrap-javascript'))
            {
                $html .= $this->jquery($config);
                JHtml::_('bootstrap.framework');

                static::setLoaded('bootstrap-javascript');

                $config->javascript = false;
            }
        }

        $html .= parent::bootstrap($config);
        return $html;
    }
334039
public function build($config)
    {
        $builder = new UrlQueryBuilder();
        $builder->setModule('API');
        $builder->setMethod($this->method);
        if ($this->usePeriod) {
            $period = $config->get(Option::PERIOD);
            $builder->setDate($this->getDate($period));
        }
        $builder->setSiteId($this->getSiteId($config));
        $formatOverride = $this->getFormat($config);
        if (!is_null($formatOverride)) {
            $builder->setFormat($this->validateFormat($formatOverride));
        }
        $builder->setTokenAuth($this->getTokenAuth($config));
        $builder->addAll($this->flattenArray($this->arguments));

        return $builder->build();
    }
1134500
public function getAdapter(array $configs)
    {
        if ($configs['force_absolute_url'] === true) {
            $this->urlRelative = $this->urlAbsolute;
        }

        return new LocalAdapter($this->path);
    }
104763
public function createOssAdapter(array $config)
    {
        $root = $config['root'] ?? null;
        $oss = new OssClient($config['access_id'], $config['access_secret'], $config['endpoint'],
            $config['isCName'] ?? false,
            $config['securityToken'] ?? null,
            $config['proxy'] ?? null
        );
        $oss->setTimeout($config['timeout'] ?? 3600);
        $oss->setConnectTimeout($config['connectTimeout'] ?? 10);
        $oss->setUseSSL($config['useSSL'] ?? false);
        return $this->adapt($this->createFlysystem(
            new OssAdapter($oss, $config['bucket'], $root), $config
        ));
    }
300607
protected function makeGoogleCloudAdapter(array $config)
    {
        $clientConfig = [
            'projectId' => $config['project_id'],
            'keyFilePath' => $config['key_file'],
        ];
        if (isset($config['auth_cache'])) {
            $clientConfig['authCache'] = $this->container->make($config['auth_cache']);
        }

        $client = $this->container->make('pubsub.gcloud.pub_sub_client', ['config' => $clientConfig]);

        $clientIdentifier = array_get($config, 'client_identifier');
        $autoCreateTopics = array_get($config, 'auto_create_topics', true);
        $autoCreateSubscriptions = array_get($config, 'auto_create_subscriptions', true);
        $backgroundBatching = array_get($config, 'background_batching', false);
        $backgroundDaemon = array_get($config, 'background_daemon', false);
        $maxMessages = array_get($config, 'max_messages', 1000);
        $returnImmediately = array_get($config, 'return_immediately', null);
        $returnImmediatelyPause = array_get($config, 'return_immediately_pause', null);

        if ($backgroundDaemon) {
            putenv('IS_BATCH_DAEMON_RUNNING=true');
        }

        return new GoogleCloudPubSubAdapter(
            $client,
            $clientIdentifier,
            $autoCreateTopics,
            $autoCreateSubscriptions,
            $backgroundBatching,
            $maxMessages,
            $returnImmediately,
            $returnImmediatelyPause
        );
    }
919402
public static function factory($config = array())
    {
        $configuration = static::buildConfig($config);

        $client = new self($configuration->get('base_url'), $configuration);

        $client->addSubscriber(new KeyAuthPlugin($configuration->get('key')));

        static::loadDefinitions($client);
        static::toggleRateLimitingPlugin($client, $config);

        return $client;
    }
631737
protected function makeKafkaAdapter(array $config)
    {
        // create producer
        $producer = $this->container->makeWith('pubsub.kafka.producer');
        $producer->addBrokers($config['brokers']);

        // create consumer
        $topicConf = $this->container->makeWith('pubsub.kafka.topic_conf');
        $topicConf->set('auto.offset.reset', 'smallest');

        $conf = $this->container->makeWith('pubsub.kafka.conf');
        $conf->set('group.id', array_get($config, 'consumer_group_id', 'php-pubsub'));
        $conf->set('metadata.broker.list', $config['brokers']);
        $conf->set('enable.auto.commit', 'false');
        $conf->set('offset.store.method', 'broker');
        $conf->setDefaultTopicConf($topicConf);

        $consumer = $this->container->makeWith('pubsub.kafka.consumer', ['conf' => $conf]);

        return new KafkaPubSubAdapter($producer, $consumer);
    }
565174
public static function create(array $config = [])
    {
        if (!isset($config['driver'])) {
            throw new InvalidArgumentException("'driver' in config missing");
        }
        if (!isset($config['drivers'][$config['driver']])) {
            throw new InvalidArgumentException("driver '{$config['driver']}' is not configured");
        }
        if (!isset($config['drivers'][$config['driver']]['tagHeaderName'])) {
            throw new InvalidArgumentException("'tagHeaderName' is not configured");
        }

        $driverConfig = $config['drivers'][$config['driver']];
        $driverClass = $driverConfig['class'] ?? self::DRIVERS_NAMESPACE . '\\' . ucfirst($config['driver']);

        // tagHeaderName and tagHeaderDelimiter are not relevant to the Purger
        unset($driverConfig['tagHeaderName'], $driverConfig['tagHeaderDelimiter']);
        return \Craft::createObject($driverClass,[$driverConfig + ['useLocalTags' => $config['useLocalTags']]]);

    }
735881
public static function factory($config = array())
    {
        $defaults = array(
            'base_url' => 'http://localhost:8983',
            'base_path' => '/solr',
            'max_query_length' => self::MAX_QUERY_LENGTH,
        );

        $required = array(
            'base_url',
            'base_path',
            'max_query_length',
        );

        // Instantiate and return the Solr client.
        $config = Collection::fromConfig($config, $defaults, $required);
        $solr = new static($config->get('base_url'), $config);

        // Use URI template expansion in a way that doesn't break Solr.
        $solr->setUriTemplate(new SolrUriTemplate());

        // Use JSON whenever possible.
        // @see http://code.google.com/p/solr-php-client/issues/detail?id=6#c1
        $jsonParams = array(
            'wt'      => 'json',
            'json.nl' => 'map',
        );

        // Sometimes we have to use XML :-(.
        $xmlParams = array(
            'wt' => 'xml',
        );

        $solr
            ->setRequestHandler(new RequestHandler('luke',    'admin/luke',      'GET',  $jsonParams))
            ->setRequestHandler(new RequestHandler('mbeans',  'admin/mbeans',    'GET',  $xmlParams + array('stats' => 'true')))
            ->setRequestHandler(new RequestHandler('mlt',     'mlt',             'GET',  $jsonParams))
            ->setRequestHandler(new RequestHandler('ping',    'admin/ping',      'HEAD', $jsonParams))
            ->setRequestHandler(new RequestHandler('select',  'select',          'GET',  $jsonParams))
            ->setRequestHandler(new RequestHandler('spell',   'spell',           'GET',  $jsonParams))
            ->setRequestHandler(new RequestHandler('stats',   'admin/stats.jsp', 'GET',  $xmlParams))
            ->setRequestHandler(new RequestHandler('suggest', 'suggest',         'GET',  $jsonParams))
            ->setRequestHandler(new RequestHandler('system',  'admin/system',    'GET',  $jsonParams))
            ->setRequestHandler(new RequestHandler('update',  'update',          'POST', $jsonParams))
        ;

        return $solr;
    }
1170779
protected function createClient(array $config)
    {
        $url = Arr::pull($config, 'url');

        $urls = parse_url($url);

        $config['host'] = $urls['host'];
        $config['port'] = $urls['port'];

        switch ($urls['scheme']) {
            case 'http':
                return new HttpClient($this->app, $this->serializerFactory, $config);
            case 'whisper':
                return new WhisperClient($this->app, $this->serializerFactory, $config);
            default:
                throw new InvalidArgumentException('Protocol '.$urls['scheme'].' is not supported for Homer.');
        }
    }
814036
protected function makeBaseClient($config)
    {
        $parameters = $this->getParameters($config);

        $client = new Client($parameters);

        $this->attachSubscribers($client);

        return $client;
    }
1212633
public static function factory($config)
    {
        static $instance = null;

        if (is_string($config)) {
            $config = new FileConfig($config);
        }

        if (! $config instanceof Config) {
            throw new \InvalidArgumentException(
                'the parameter $xmlConfig has to be a path to a config file or an instance of \Wurfl\Configuration\Config'
            );
        }

        if (null === $instance) {
            // Create the cache instance from the configuration
            $cacheStorage = Storage\Factory::create($config->cache);

            // Create the persistent cache instance from the configuration
            $persistenceStorage = Storage\Factory::create($config->persistence);

            $instance = new self($config, $persistenceStorage, $cacheStorage);
        }

        return $instance;
    }
550899
protected function getClient(array $config)
    {
        $name = array_get($config, 'adapter');
        $config = $this->manager->getConnectionConfig($name);

        return $this->manager->getFactory()->createAdapter($config);
    }