Skip to content

Commit e610edc

Browse files
Fixes on merging handler stack already passed from constructor params
1 parent 8b340f8 commit e610edc

File tree

5 files changed

+14
-5
lines changed

5 files changed

+14
-5
lines changed

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,4 +89,4 @@
8989

9090
### 0.3.1 - Logger Handler fix
9191

92-
### 0.3.2 - Response and Request handler can now be defined as a class member
92+
### 0.3.2 - Response and Request handler can now be defined as a class member

composer.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
],
1616
"require": {
1717
"php": ">=7.0.0",
18+
"ext-json": "*",
1819
"guzzlehttp/guzzle-services": "^1.1",
1920
"doctrine/inflector": "^1.3",
2021
"monolog/monolog": "^2.0"

src/support/forge/api/Client.php

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,15 @@ protected function setOptions($options = [])
7878
$defaults['description']['jsonPath'] = realpath($this->rootPath . $this->DEFAULT_API_JSON_PATH);
7979
$mergedOptions = array_replace_recursive($defaults, $options);
8080
$parsedOptions = $this->parseOptions($mergedOptions, $options);
81+
82+
$handlers = $this->getStacks($parsedOptions);
83+
if (!empty($handlers)) {
84+
if (empty($parsedOptions['client'])) {
85+
$parsedOptions['client'] = [];
86+
}
87+
$parsedOptions['client']['handler'] = $handlers;
88+
}
89+
8190
$this->options = $parsedOptions;
8291

8392
return $this;
@@ -136,7 +145,7 @@ protected function setDescription($descriptionOptions = [])
136145
$description = [];
137146

138147
if (!empty($jsonPath)) {
139-
$description = json_decode(file_get_contents($jsonPath), true);
148+
$description = \GuzzleHttp\json_decode(file_get_contents($jsonPath), true);
140149
}
141150
if (empty($description)) {
142151
$description = [];
@@ -173,7 +182,6 @@ protected function createClient($clientOptions = [])
173182
*/
174183
protected function setClient($clientOptions = [])
175184
{
176-
177185
$this->createClient($clientOptions);
178186
$this->consumer = new GuzzleClient($this->client, $this->description);
179187

src/support/forge/api/Traits/Client/Stackables.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ trait Stackables
1919
protected function getStacks($config)
2020
{
2121

22-
$stack = HandlerStack::create();
22+
$stack = $config['client']['handler'] ?? HandlerStack::create();
2323

2424
if (!empty($config['settings']['requestHandler'])) {
2525
$request = $this->getRequestStack($config['settings']['requestHandler']);

src/support/forge/api/Traits/Import/Parsers.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ protected function parseParams($url = [], $bodyRaw = '', $meta = [])
111111
}
112112
}
113113

114-
$rawParams = json_decode($bodyRaw, true);
114+
$rawParams = \GuzzleHttp\json_decode($bodyRaw, true);
115115
if (!empty($rawParams)) {
116116
foreach ($rawParams as $paramName => $paramItem) {
117117
$params[$paramName] = [

0 commit comments

Comments
 (0)