Skip to content

Commit 3940a27

Browse files
committed
moved the mutator key to client key
1 parent 3209af1 commit 3940a27

File tree

2 files changed

+11
-11
lines changed

2 files changed

+11
-11
lines changed

src/Elasticsearch/Endpoints/AbstractEndpoint.php

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -249,6 +249,15 @@ private function extractOptions(&$params)
249249
{
250250
// Extract out client options, then start transforming
251251
if (isset($params['client']) === true) {
252+
// Check if the opaqueId is populated and add the header
253+
if (isset($params['client']['opaqueId']) === true) {
254+
if (isset($params['client']['headers']) === false) {
255+
$params['client']['headers'] = [];
256+
}
257+
$params['client']['headers']['x-opaque-id'] = [trim($params['client']['opaqueId'])];
258+
unset($params['client']['opaqueId']);
259+
}
260+
252261
$this->options['client'] = $params['client'];
253262
unset($params['client']);
254263
}
@@ -262,15 +271,6 @@ private function extractOptions(&$params)
262271
$this->options['client']['ignore'] = [$ignore];
263272
}
264273
}
265-
266-
// Check if the opaqueId is populated and add the header
267-
if (isset($params['opaqueId']) === true) {
268-
if (isset($this->options['client']['headers']) === false) {
269-
$this->options['client']['headers'] = [];
270-
}
271-
$this->options['client']['headers']['x-opaque-id'] = [trim($params['opaqueId'])];
272-
unset($params['opaqueId']);
273-
}
274274
}
275275

276276
private function convertCustom(array $params): array

tests/Elasticsearch/Tests/Endpoints/AbstractEndpointTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,15 +46,15 @@ public function testInvalidParamsCauseErrorsWhenProvidedToSetParams(array $param
4646
*/
4747
public function testOpaqueIdInHeaders()
4848
{
49-
$params = ['opaqueId' => 'test_id_' . rand(1000, 9999)];
49+
$params = ['client' => ['opaqueId' => 'test_id_' . rand(1000, 9999)]];
5050
$this->endpoint->setParams($params);
5151

5252
$options = $this->endpoint->getOptions();
5353
$this->assertArrayHasKey('client', $options);
5454
$this->assertArrayHasKey('headers', $options['client']);
5555
$this->assertArrayHasKey('x-opaque-id', $options['client']['headers']);
5656
$this->assertNotEmpty($options['client']['headers']['x-opaque-id']);
57-
$this->assertEquals($params['opaqueId'], $options['client']['headers']['x-opaque-id'][0]);
57+
$this->assertEquals($params['client']['opaqueId'], $options['client']['headers']['x-opaque-id'][0]);
5858
}
5959

6060
}

0 commit comments

Comments
 (0)