Fixed guzzle client with check for guzzle 6 and reverted guzzle 4 and 5 to their correct building.

This commit is contained in:
Paul Young
2016-02-18 09:10:41 +10:30
parent 5b4bda64ff
commit d153ae7158

View File

@@ -70,6 +70,8 @@ class GoutteFactory implements DriverFactory
if ($this->isGoutte1()) {
$guzzleClient = $this->buildGuzzle3Client($config['guzzle_parameters']);
} elseif ($this->isGuzzle6()) {
$guzzleClient = $this->buildGuzzle6Client($config['guzzle_parameters']);
} else {
$guzzleClient = $this->buildGuzzle4Client($config['guzzle_parameters']);
}
@@ -84,14 +86,22 @@ class GoutteFactory implements DriverFactory
));
}
private function buildGuzzle4Client(array $parameters)
private function buildGuzzle6Client(array $parameters)
{
// Force the parameters set by default in Goutte to reproduce its behavior
$parameters['allow_redirects'] = false;
$parameters['cookies'] = true;
return new Definition('GuzzleHttp\Client', array($parameters));
}
private function buildGuzzle4Client(array $parameters)
{
// Force the parameters set by default in Goutte to reproduce its behavior
$parameters['allow_redirects'] = false;
$parameters['cookies'] = true;
return new Definition('GuzzleHttp\Client', array(array('defaults' => $parameters)));
}
private function buildGuzzle3Client(array $parameters)
@@ -112,4 +122,10 @@ class GoutteFactory implements DriverFactory
return false;
}
private function isGuzzle6()
{
return interface_exists('GuzzleHttp\ClientInterface') &&
version_compare(\GuzzleHttp\ClientInterface::VERSION, '6.0.0', '>=');
}
}