2017-07-31 15:50:48 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
namespace App\Service;
|
|
|
|
|
|
|
|
|
|
use Interop\Container\ContainerInterface;
|
|
|
|
|
use Zend\Config\Config;
|
|
|
|
|
use Zend\Http\Client;
|
|
|
|
|
|
|
|
|
|
class DataCollectorServiceFactory
|
|
|
|
|
{
|
|
|
|
|
public function __invoke(ContainerInterface $container)
|
|
|
|
|
{
|
|
|
|
|
$configArray = $container->get('config');
|
|
|
|
|
$config = new Config($configArray['app.config']);
|
2017-07-31 16:49:50 +02:00
|
|
|
$httpClient = new Client();
|
|
|
|
|
$httpClient->setAdapter($curlAdapter = new Client\Adapter\Curl());
|
2017-08-01 18:16:33 +02:00
|
|
|
$curlAdapter->setOptions(['timeout' => 300]);
|
2017-07-31 16:49:50 +02:00
|
|
|
if($config->get('http.proxy.enabled', false)) {
|
|
|
|
|
$curlAdapter
|
|
|
|
|
->setCurlOption(CURLOPT_PROXYTYPE, $config->get('http.proxy.type'))
|
|
|
|
|
->setCurlOption(CURLOPT_PROXY, $config->get('http.proxy.url'));
|
|
|
|
|
}
|
2017-07-31 15:50:48 +02:00
|
|
|
$avatarService = $container->get(AvatarService::class);
|
|
|
|
|
return new DataCollectorService($httpClient, $config, $avatarService);
|
|
|
|
|
}
|
|
|
|
|
}
|