Skip to content

Commit

Permalink
Changes required for Guzzle 6
Browse files Browse the repository at this point in the history
  • Loading branch information
Zeno Zaplaic committed Apr 25, 2019
1 parent 2ab3b2e commit 20b39a7
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 10 deletions.
19 changes: 10 additions & 9 deletions src/Funnelback/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ class Client implements ClientInterface
*/
public function __construct(array $config, HttpClientInterface $client = null)
{
$this->baseUrl = $config['base_url'];
$this->baseUrl = $config['base_uri'];
$this->subPath = isset($config['sub_path']) ? $config['sub_path'] : '';
$format = isset($config['format']) ? $config['format'] : self::JSON_FORMAT;
$this->setFormat($format);
Expand All @@ -77,15 +77,11 @@ public function __construct(array $config, HttpClientInterface $client = null)
*/
public function getClient()
{
$baseUri = sprintf('%s/s/search.%s', $this->getBaseUrl(), $this->getFormat());
$defaults = ['collection' => $this->getCollection()];
if (!isset($this->client)) {
$this->client = new HttpClient([
'base_url' => [
'{base_url}/s/search.{format}',
['base_url' => $this->getBaseUrl(), 'format' => $this->getFormat()]
],
'defaults' => [
'query' => ['collection' => $this->getCollection()],
]
'base_uri' => $baseUri,
]);
}

Expand Down Expand Up @@ -160,7 +156,12 @@ public function allowedFormats()
*/
public function search($query, $params = [])
{
$params = array_merge(['query' => $query], $params);

$params = array_merge(
['collection' => $this->getCollection()],
['query' => $query],
$params
);
$http_response = $this->getClient()->get(null, ['query' => $params]);

return new Response($http_response);
Expand Down
2 changes: 1 addition & 1 deletion tests/Funnelback/ClientTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public function testSearch()
$http_client = new HttpClient(['handler' => $handlerStack]);

$config = [
'base_url' => 'http://agencysearch.australia.gov.au',
'base_uri' => 'http://agencysearch.australia.gov.au',
'collection' => 'agencies',
];

Expand Down

0 comments on commit 20b39a7

Please sign in to comment.