Skip to content

Commit

Permalink
added condition for options, if value is null or empty array it will …
Browse files Browse the repository at this point in the history
…not be set (#41)
  • Loading branch information
Florian Preusner committed Apr 28, 2016
1 parent d79f2fc commit ae14e6e
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions DependencyInjection/GuzzleExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,17 @@ public function load(array $configs, ContainerBuilder $container) {
'handler' => $this->createHandler($container, $name, $options)
];

// If present, add default options to the constructor argument for the Guzzle client
if (array_key_exists('options', $options)) {
$argument = array_merge($options['options'], $argument);
// if present, add default options to the constructor argument for the Guzzle client
if (array_key_exists('options', $options) && is_array($options['options'])) {

foreach($options['options'] as $key => $value) {

if($value === null || (is_array($value) && count($value) === 0)) {
continue;
}

$argument[$key] = $value;
}
}

$client = new Definition('%guzzle.http_client.class%');
Expand Down

0 comments on commit ae14e6e

Please sign in to comment.