Skip to content

Commit add7a10

Browse files
committed
Merge branch 'hwde-byExample' into devel
2 parents 97b95a3 + 8cf7f9b commit add7a10

File tree

2 files changed

+23
-3
lines changed

2 files changed

+23
-3
lines changed

lib/ArangoDBClient/BatchPart.php

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -246,6 +246,16 @@ public function getProcessedResponse()
246246

247247
$response = $this->getResponse();
248248
switch ($this->_type) {
249+
case 'first':
250+
$json = $response->getJson();
251+
if (!isset($json['error']) || $json['error'] === false) {
252+
$options = $this->getCursorOptions();
253+
$options['_isNew'] = false;
254+
$response = $_documentClass::createFromArray($json['document'], $options);
255+
} else {
256+
$response = false;
257+
}
258+
break;
249259
case 'getdocument':
250260
$json = $response->getJson();
251261
$options = $this->getCursorOptions();
@@ -294,8 +304,9 @@ public function getProcessedResponse()
294304
break;
295305
case 'cursor':
296306
case 'all':
297-
$options = $this->getCursorOptions();
298-
$options['_isNew'] = false;
307+
case 'by':
308+
$options = $this->getCursorOptions();
309+
$options['isNew'] = false;
299310

300311
$options = array_merge(['_documentClass' => $this->_documentClass], $options);
301312
$response = new Cursor($this->_batch->getConnection(), $response->getJson(), $options);

lib/ArangoDBClient/CollectionHandler.php

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1255,7 +1255,11 @@ public function byExample($collectionId, $document, array $options = [])
12551255

12561256
$response = $this->getConnection()->put(Urls::URL_EXAMPLE, $this->json_encode_wrapper($body));
12571257

1258-
$options['_isNew'] = false;
1258+
if ($batchPart = $response->getBatchPart()) {
1259+
return $batchPart;
1260+
}
1261+
1262+
$options['isNew'] = false;
12591263

12601264
$options = array_merge(['_documentClass' => $this->_documentClass], $options);
12611265

@@ -1305,6 +1309,11 @@ public function firstExample($collectionId, $document, array $options = [])
13051309
];
13061310

13071311
$response = $this->getConnection()->put(Urls::URL_FIRST_EXAMPLE, $this->json_encode_wrapper($data));
1312+
1313+
if ($batchPart = $response->getBatchPart()) {
1314+
return $batchPart;
1315+
}
1316+
13081317
$data = $response->getJson();
13091318

13101319
$options['_isNew'] = false;

0 commit comments

Comments
 (0)