Maurits van der Schee před 3 roky
rodič
revize
03ba82c3a1
1 změnil soubory, kde provedl 9 přidání a 9 odebrání
  1. 9
    9
      src/Tqdev/PhpCrudApi/Controller/RecordController.php

+ 9
- 9
src/Tqdev/PhpCrudApi/Controller/RecordController.php Zobrazit soubor

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

Loading…
Zrušit
Uložit