protected function HttpClient::getClientByCommand in HTTP Client Manager 8.2
Get Client by Command.
Get or create an instance of the Guzzle Client, with overridden configurations or not, based on the given command name. If the service api description has been overridden via settings.php and has been defined a "commands['whitelist']" or "commands['blacklist']" property, the following algorithm will be applied:
- Commands in blacklist or not in whitelist must not use service overrides.
- All the other commands will use the service overrides.
Parameters
string $commandName: The Guzzle Command name.
Return value
\GuzzleHttp\Command\Guzzle\GuzzleClient The Configured Guzzle client instance
1 call to HttpClient::getClientByCommand()
- HttpClient::call in src/
HttpClient.php - Execute command call.
File
- src/
HttpClient.php, line 171
Class
- HttpClient
- The http client.
Namespace
Drupal\http_client_managerCode
protected function getClientByCommand($commandName) {
$api = $this
->getApi();
if (empty($api['orig']) || empty($api['commands'])) {
return $this
->getClient();
}
$cmds = $api['commands'];
$config = $api['config'];
// Commands in blacklist or not in whitelist must not use service overrides.
if (!empty($cmds['blacklist']) && in_array($commandName, $cmds['blacklist']) || !empty($cmds['whitelist']) && !in_array($commandName, $cmds['whitelist'])) {
$config = $api['orig']['config'];
$config['handler'] = $this
->getClientConfig()['handler'];
}
$this->client = $this
->createGuzzleClient($config);
return $this->client;
}