Skip to content

Commit 5394796

Browse files
committed
Do a json_encode() dynamically if $content is an array
Make the \Flowpack\ElasticSearch\Domain\Model\Client API more high-level and more flexible.
1 parent d15a99b commit 5394796

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

Classes/Flowpack/ElasticSearch/Domain/Model/Client.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ public function findIndex($indexName) {
8585
* @param string $method
8686
* @param string $path
8787
* @param array $arguments
88-
* @param string $content
88+
* @param string|array $content
8989
*
9090
* @return \Flowpack\ElasticSearch\Transfer\Response
9191
*/

Classes/Flowpack/ElasticSearch/Transfer/RequestService.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ public function initializeObject() {
5353
* @param \Flowpack\ElasticSearch\Domain\Model\Client $client
5454
* @param string $path
5555
* @param array $arguments
56-
* @param string $content
56+
* @param string|array $content
5757
*
5858
* @return \Flowpack\ElasticSearch\Transfer\Response
5959
*/
@@ -66,7 +66,8 @@ public function request($method, \Flowpack\ElasticSearch\Domain\Model\Client $cl
6666
$uri->setPath($uri->getPath() . $path);
6767
}
6868

69-
$response = $this->browser->request($uri, $method, $arguments, array(), array(), $content);
69+
$response = $this->browser->request($uri, $method, $arguments, array(), array(),
70+
is_array($content) ? json_encode($content) : $content);
7071

7172
return new Response($response, $this->browser->getLastRequest());
7273
}

0 commit comments

Comments
 (0)