Browse Source

improved fix for #744

Maurits van der Schee 3 years ago
parent
commit
03ba82c3a1
1 changed files with 9 additions and 9 deletions
  1. 9
    9
      src/Tqdev/PhpCrudApi/Controller/RecordController.php

+ 9
- 9
src/Tqdev/PhpCrudApi/Controller/RecordController.php View File

@@ -46,11 +46,11 @@ class RecordController
46 46
         $params = RequestUtils::getParams($request);
47 47
         if (strpos($id, ',') !== false) {
48 48
             $ids = explode(',', $id);
49
-            $result = [];
49
+            $argumentLists = array();
50 50
             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);
52 52
             }
53
-            return $this->responder->success($result);
53
+            return $this->responder->multi($this->multiCall([$this->service, 'read'], $argumentLists));
54 54
         } else {
55 55
             $response = $this->service->read($table, $id, $params);
56 56
             if ($response === null) {
@@ -152,11 +152,11 @@ class RecordController
152 152
         $params = RequestUtils::getParams($request);
153 153
         $ids = explode(',', $id);
154 154
         if (count($ids) > 1) {
155
-            $result = array();
155
+            $argumentLists = array();
156 156
             for ($i = 0; $i < count($ids); $i++) {
157
-                $result[] = $this->service->delete($table, $ids[$i], $params);
157
+                $argumentLists[] = array($table, $ids[$i], $params);
158 158
             }
159
-            return $this->responder->success($result);
159
+            return $this->responder->multi($this->multiCall([$this->service, 'delete'], $argumentLists));
160 160
         } else {
161 161
             return $this->responder->success($this->service->delete($table, $id, $params));
162 162
         }
@@ -182,11 +182,11 @@ class RecordController
182 182
             if (count($ids) != count($record)) {
183 183
                 return $this->responder->error(ErrorCode::ARGUMENT_COUNT_MISMATCH, $id);
184 184
             }
185
-            $result = array();
185
+            $argumentLists = array();
186 186
             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);
188 188
             }
189
-            return $this->responder->success($result);
189
+            return $this->responder->multi($this->multiCall([$this->service, 'increment'], $argumentLists));
190 190
         } else {
191 191
             if (count($ids) != 1) {
192 192
                 return $this->responder->error(ErrorCode::ARGUMENT_COUNT_MISMATCH, $id);

Loading…
Cancel
Save