Elgg  Version master
Client.php
Go to the documentation of this file.
1 <?php
2 
3 namespace Elgg\Http;
4 
5 use GuzzleHttp\Client as GuzzleClient;
7 
13 class Client extends GuzzleClient {
14 
18  public function __construct(array $options = []) {
19 
20  $proxy_config = (array) elgg_get_config('proxy', []);
21 
22  $defaults = [
23  RequestOptions::TIMEOUT => 5,
24  RequestOptions::HTTP_ERRORS => false,
25  RequestOptions::VERIFY => (bool) elgg_extract('verify_ssl', $proxy_config, true),
26  ];
27 
28  $host = elgg_extract('host', $proxy_config);
29  if (!empty($host)) {
30  $port = (int) elgg_extract('port', $proxy_config);
31  if ($port > 0) {
32  $host = rtrim($host, ':') . ":{$port}";
33  }
34 
35  $defaults[RequestOptions::PROXY] = $host;
36  }
37 
38  $options = array_merge($defaults, $options);
39 
40  parent::__construct($options);
41  }
42 }
elgg_get_config(string $name, $default=null)
Get an Elgg configuration value.
$defaults
Generic entity header upload helper.
Definition: header.php:6
Helper class to construct a Guzzle Client with the correct defaults.
Definition: Client.php:13
__construct(array $options=[])
{}
Definition: Client.php:18
elgg_extract($key, $array, $default=null, bool $strict=true)
Checks for $array[$key] and returns its value if it exists, else returns $default.
Definition: elgglib.php:254
if($who_can_change_language=== 'nobody') elseif($who_can_change_language=== 'admin_only'&&!elgg_is_admin_logged_in()) $options
Definition: language.php:20