Example #1
0
 /**
  * Common adapters constructor.
  *
  * @param array               $config
  * @param HttpClientInterface $httpClient
  * @param StorageInterface    $storage
  * @param LoggerInterface     $logger
  */
 public function __construct($config = [], HttpClientInterface $httpClient = null, StorageInterface $storage = null, LoggerInterface $logger = null)
 {
     $this->providerId = str_replace('Hybridauth\\Provider\\', '', get_class($this));
     $this->storage = $storage ?: new Session();
     $this->logger = $logger ?: new Logger(isset($config['debug_mode']) ? $config['debug_mode'] : Logger::NONE, isset($config['debug_file']) ? $config['debug_file'] : '');
     $this->httpClient = $httpClient ?: new HttpClient();
     if (isset($config['curl_options']) && method_exists($this->httpClient, 'setCurlOptions')) {
         $this->httpClient->setCurlOptions($this->config['curl_options']);
     }
     if (method_exists($this->httpClient, 'setLogger')) {
         $this->httpClient->setLogger($this->logger);
     }
     $this->logger->debug('Initialize ' . get_class($this) . '. Provider config: ', $config);
     $this->config = new Data\Collection($config);
     $this->endpoint = $this->config->get('callback');
     $this->initialize();
 }