create-prisma-php-app 2.0.4 → 2.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bootstrap.php +23 -30
- package/package.json +1 -1
package/dist/bootstrap.php
CHANGED
|
@@ -543,27 +543,28 @@ final class Bootstrap
|
|
|
543
543
|
$callbackResponse = null;
|
|
544
544
|
$data = [];
|
|
545
545
|
|
|
546
|
-
// Check if the request includes one or more files
|
|
547
|
-
$hasFile = isset($_FILES['file']) && !empty($_FILES['file']['name'][0]);
|
|
548
|
-
|
|
549
546
|
// Process form data
|
|
550
|
-
if ($
|
|
547
|
+
if (!empty($_FILES)) {
|
|
551
548
|
$data = $_POST;
|
|
552
549
|
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
550
|
+
// Iterate over each file key in $_FILES
|
|
551
|
+
foreach ($_FILES as $key => $file) {
|
|
552
|
+
// Check if it's a multiple file upload or a single file upload
|
|
553
|
+
if (is_array($file['name'])) {
|
|
554
|
+
$files = [];
|
|
555
|
+
foreach ($file['name'] as $index => $name) {
|
|
556
|
+
$files[] = [
|
|
557
|
+
'name' => $name,
|
|
558
|
+
'type' => $file['type'][$index],
|
|
559
|
+
'tmp_name' => $file['tmp_name'][$index],
|
|
560
|
+
'error' => $file['error'][$index],
|
|
561
|
+
'size' => $file['size'][$index],
|
|
562
|
+
];
|
|
563
|
+
}
|
|
564
|
+
$data[$key] = $files;
|
|
565
|
+
} else {
|
|
566
|
+
$data[$key] = $file;
|
|
563
567
|
}
|
|
564
|
-
$data['files'] = $files;
|
|
565
|
-
} else {
|
|
566
|
-
$data['file'] = $_FILES['file'];
|
|
567
568
|
}
|
|
568
569
|
} else {
|
|
569
570
|
$input = file_get_contents('php://input');
|
|
@@ -582,18 +583,10 @@ final class Bootstrap
|
|
|
582
583
|
$dataObject = self::convertToArrayObject($data);
|
|
583
584
|
// Call the function
|
|
584
585
|
$callbackResponse = call_user_func($callbackName, $dataObject);
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
'response' => $callbackResponse
|
|
590
|
-
];
|
|
591
|
-
} else {
|
|
592
|
-
$response = [
|
|
593
|
-
'success' => true,
|
|
594
|
-
'response' => $callbackResponse
|
|
595
|
-
];
|
|
596
|
-
}
|
|
586
|
+
$response = [
|
|
587
|
+
'success' => true,
|
|
588
|
+
'response' => $callbackResponse
|
|
589
|
+
];
|
|
597
590
|
} else {
|
|
598
591
|
if ($callbackName === PrismaPHPSettings::$localStoreKey) {
|
|
599
592
|
$response = [
|
|
@@ -608,7 +601,7 @@ final class Bootstrap
|
|
|
608
601
|
$response['error'] = 'No callback provided';
|
|
609
602
|
}
|
|
610
603
|
|
|
611
|
-
// Output the JSON response only if the callbackResponse is not null
|
|
604
|
+
// Output the JSON response only if the callbackResponse is not null or if there's an error
|
|
612
605
|
if ($callbackResponse !== null || isset($response['error'])) {
|
|
613
606
|
echo json_encode($response);
|
|
614
607
|
}
|