Skip to content

Commit 03ba82c

Browse files
committed
improved fix for #744
1 parent fabc8e4 commit 03ba82c

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

src/Tqdev/PhpCrudApi/Controller/RecordController.php

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -46,11 +46,11 @@ public function read(ServerRequestInterface $request): ResponseInterface
4646
$params = RequestUtils::getParams($request);
4747
if (strpos($id, ',') !== false) {
4848
$ids = explode(',', $id);
49-
$result = [];
49+
$argumentLists = array();
5050
for ($i = 0; $i < count($ids); $i++) {
51-
array_push($result, $this->service->read($table, $ids[$i], $params));
51+
$argumentLists[] = array($table, $ids[$i], $params);
5252
}
53-
return $this->responder->success($result);
53+
return $this->responder->multi($this->multiCall([$this->service, 'read'], $argumentLists));
5454
} else {
5555
$response = $this->service->read($table, $id, $params);
5656
if ($response === null) {
@@ -152,11 +152,11 @@ public function delete(ServerRequestInterface $request): ResponseInterface
152152
$params = RequestUtils::getParams($request);
153153
$ids = explode(',', $id);
154154
if (count($ids) > 1) {
155-
$result = array();
155+
$argumentLists = array();
156156
for ($i = 0; $i < count($ids); $i++) {
157-
$result[] = $this->service->delete($table, $ids[$i], $params);
157+
$argumentLists[] = array($table, $ids[$i], $params);
158158
}
159-
return $this->responder->success($result);
159+
return $this->responder->multi($this->multiCall([$this->service, 'delete'], $argumentLists));
160160
} else {
161161
return $this->responder->success($this->service->delete($table, $id, $params));
162162
}
@@ -182,11 +182,11 @@ public function increment(ServerRequestInterface $request): ResponseInterface
182182
if (count($ids) != count($record)) {
183183
return $this->responder->error(ErrorCode::ARGUMENT_COUNT_MISMATCH, $id);
184184
}
185-
$result = array();
185+
$argumentLists = array();
186186
for ($i = 0; $i < count($ids); $i++) {
187-
$result[] = $this->service->increment($table, $ids[$i], $record[$i], $params);
187+
$argumentLists[] = array($table, $ids[$i], $record[$i], $params);
188188
}
189-
return $this->responder->success($result);
189+
return $this->responder->multi($this->multiCall([$this->service, 'increment'], $argumentLists));
190190
} else {
191191
if (count($ids) != 1) {
192192
return $this->responder->error(ErrorCode::ARGUMENT_COUNT_MISMATCH, $id);

0 commit comments

Comments
 (0)