Create a new BotMan instance.

@param array $config
@param RealTimeClient $client
@param CacheInterface $cache
@param StorageInterface $storageDriver
@return BotMan
@internal param LoopInterface $loop
193412
public function createUsingRTM(
        array $config,
        RealTimeClient $client,
        CacheInterface $cache = null,
        StorageInterface $storageDriver = null
    ) {
        if (empty($cache)) {
            $cache = new ArrayCache();
        }

        if (empty($storageDriver)) {
            $storageDriver = new FileStorage(__DIR__);
        }

        $config = Collection::make(Collection::make($config)->get('slack', []));
        $client->setToken($config->get('token'));

        $driver = new SlackRTMDriver($config->toArray(), $client);
        $botman = new BotMan($cache, $driver, $config->toArray(), $storageDriver);

        $client->on('_internal_message', function () use ($botman) {
            $botman->listen();
        });

        $client->connect()->then(function () use ($driver) {
            echo "\033[32mSuccessfully connected\033[0m".PHP_EOL;
            $driver->connected();
        })->otherwise(function (\Exception $e) {
            echo "\033[31mError: ".$e->getMessage()."\033[0m".PHP_EOL;
        });

        return $botman;
    }
468834
protected function getAdapter(Store $client, array $config)
    {
        $key = array_get($config, 'key', 'flysystem');
        $ttl = array_get($config, 'ttl');

        return new IlluminateCache($client, $key, $ttl);
    }
654098
public static function newInstance($apiKey, Configuration $config = null)
    {
        if ($config === null) {
            $config = new Configuration();
        }

        $eventDispatcher       = Swift_DependencyContainer::getInstance()->lookup('transport.eventdispatcher');
        $guzzle                = new GuzzleAdapter(new GuzzleClient(['http_errors' => false, 'timeout' => 300]));
        $sparkpost             = new SparkPost($guzzle, ['key' => $apiKey]);
        $randomNumberGenerator = new MtRandomNumberGenerator();
        $payloadBuilder        = new StandardPayloadBuilder($config, $randomNumberGenerator);

        return new self($eventDispatcher, $sparkpost, $payloadBuilder);
    }
1129655
public function getConfiguration(array $config, ContainerBuilder $container)
    {
        $reflection = new \ReflectionClass(Configuration::class);
        $container->addResource(new FileResource($reflection->getFileName()));

        return new Configuration();
    }
367058
private function registerClients(array $config, ContainerBuilder $container)
    {
        foreach ($config['clients'] as $clientType => $clients) {
            $clientFQCN = ($clientType == 'apns') ? 'LinkValue\MobileNotifBundle\Client\ApnsClient' : 'LinkValue\MobileNotifBundle\Client\GcmClient';

            foreach ($clients as $clientName => $clientConfig) {
                $params = isset($clientConfig['params']) ? $clientConfig['params'] : array();
                $services = isset($clientConfig['services']) ? $clientConfig['services'] : array();

                // The final client name is a concatenation of the client type (apns/gcm) and the client name (defined by user) separated by a point '.'
                $clientName = sprintf('%s.%s', $clientType, $clientName);

                // Register client with required stuff
                $client = $container->register(sprintf('link_value_mobile_notif.clients.%s', $clientName), $clientFQCN)
                    ->addMethodCall('setUp', array($params))
                    ->addTag('link_value_mobile_notif.client', array('name' => $clientName))
                ;

                // Set optional logger
                if(!empty($services['logger'])) {
                    $client->addMethodCall('setLogger', array(new Reference($services['logger'])));
                }

                // Set optional profiler
                if(!empty($services['profiler'])) {
                    $client->addMethodCall('setClientProfiler', array(new Reference($services['profiler'])));
                }
            }
        }
    }
751860
public static function createForSocket(
        array $config,
        LoopInterface $loop,
        CacheInterface $cache = null,
        StorageInterface $storageDriver = null
    ) {
        $port = isset($config['port']) ? $config['port'] : 8080;

        $socket = new Server($loop);

        if (empty($cache)) {
            $cache = new ArrayCache();
        }

        if (empty($storageDriver)) {
            $storageDriver = new FileStorage(__DIR__);
        }

        $driverManager = new DriverManager($config, new Curl());

        $botman = new BotMan($cache, DriverManager::loadFromName('Null', $config), $config, $storageDriver);
        $botman->runsOnSocket(true);

        $socket->on('connection', function ($conn) use ($botman, $driverManager) {
            $conn->on('data', function ($data) use ($botman, $driverManager) {
                $requestData = json_decode($data, true);
                $request = new Request($requestData['query'], $requestData['request'], $requestData['attributes'], [], [], [], $requestData['content']);
                $driver = $driverManager->getMatchingDriver($request);
                $botman->setDriver($driver);
                $botman->listen();
            });
        });
        $socket->listen($port);

        return $botman;
    }
798670
public function load(ContainerBuilder $container, array $config)
    {
        $this->loadPauser($container);
        $this->loadController($container);
        $this->loadListener($container);
    }
931863
public function addCache(CacheItemPoolInterface $cachePool, array $config = [])
    {
        $this->cachePlugin = new CachePlugin(
            $cachePool,
            $this->streamFactory,
            $config['generator'] ?? null,
            $config['lifetime'] ?? null
        );

        $this->httpClientModified = true;
    }
345306
public function make(array $config): Client
    {
        $config = $this->getConfig($config);

        return $this->getClient($config);
    }
369641
public function make(array $config)
    {
        $client = $this->createClient($config);
        $zone = new ZoneRepository($client);
        $ip = new IpRepository($client);

        return new CloudFlareAPI($zone, $ip);
    }
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;
    }
1158155
protected function getClient(array $config)
    {
        $name = array_get($config, 'connector');

        return $this->cache->driver($name)->getStore();
    }
1264784
private function createClient($config)
    {
        $keyFile = array_get($config, 'key_file');
        if (is_string($keyFile)) {
            return new StorageClient([
                'projectId' => $config['project_id'],
                'keyFilePath' => $keyFile,
            ]);
        }

        if (! is_array($keyFile)) {
            $keyFile = [];
        }
        return new StorageClient([
            'projectId' => $config['project_id'],
            'keyFile' => array_merge(["project_id" => $config['project_id']], $keyFile)
        ]);
    }
815334
protected function createClient($id, $config)
    {
        $config['id'] = $id;

        if (!isset($config['httpClient']) && $this->httpClient !== null) {
            $config['httpClient'] = $this->httpClient;
        }

        return Yii::createObject($config);
    }
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);
    }
874644
private function configureEntityManager(array $config, ContainerBuilder $container)
    {
        $container->register('doctrine.key_value.configuration', 'Doctrine\KeyValueStore\Configuration')
            ->addMethodCall('setMappingDriverImpl', array(new Reference('doctrine.key_value.metadata.annotation')));

        $container->register('doctrine.key_value.entity_manager', 'Doctrine\KeyValueStore\EntityManager')
            ->addArgument(new Reference('doctrine.key_value.storage'))
            ->addArgument(new Reference('doctrine.key_value.configuration'));
    }
854288
protected function createMemcachedDriver( array $config )
	{
		$prefix = $this->getPrefix( $config );

		$memcached = MemcachedConnector::i()->connect( $config['servers'] );

		return new MemcachedStore( $memcached, $prefix );
	}