Skip to content

Commit 841474b

Browse files
committed
Merge branch 'master' of github.com:mevdschee/php-crud-api
2 parents de1bf04 + d8833c5 commit 841474b

File tree

4 files changed

+37
-33
lines changed

4 files changed

+37
-33
lines changed

README.md

+25-24
Original file line numberDiff line numberDiff line change
@@ -572,7 +572,7 @@ of the batch failed due to an integrity violation:
572572
}
573573
]
574574

575-
The response status code will always be 424 (failed dependency) in case of failure of one of the batch operations.
575+
The response status code will always be 424 (failed dependency) in case of any failure of one of the batch operations.
576576

577577
### Spatial support
578578

@@ -1183,29 +1183,29 @@ The valid floating point values 'Infinite' (calculated with '1/0') and 'Not a Nu
11831183

11841184
The following errors may be reported:
11851185

1186-
| Error | HTTP response code | Message
1187-
| ------| -------------------------- | --------------
1188-
| 1000 | 404 Not found | Route not found
1189-
| 1001 | 404 Not found | Table not found
1190-
| 1002 | 422 Unprocessable entity | Argument count mismatch
1191-
| 1003 | 404 Not found | Record not found
1192-
| 1004 | 403 Forbidden | Origin is forbidden
1193-
| 1005 | 404 Not found | Column not found
1194-
| 1006 | 409 Conflict | Table already exists
1195-
| 1007 | 409 Conflict | Column already exists
1196-
| 1008 | 422 Unprocessable entity | Cannot read HTTP message
1197-
| 1009 | 409 Conflict | Duplicate key exception
1198-
| 1010 | 409 Conflict | Data integrity violation
1199-
| 1011 | 401 Unauthorized | Authentication required
1200-
| 1012 | 403 Forbidden | Authentication failed
1201-
| 1013 | 422 Unprocessable entity | Input validation failed
1202-
| 1014 | 403 Forbidden | Operation forbidden
1203-
| 1015 | 405 Method not allowed | Operation not supported
1204-
| 1016 | 403 Forbidden | Temporary or permanently blocked
1205-
| 1017 | 403 Forbidden | Bad or missing XSRF token
1206-
| 1018 | 403 Forbidden | Only AJAX requests allowed
1207-
| 1019 | 403 Forbidden | Pagination Forbidden
1208-
| 9999 | 500 Internal server error | Unknown error
1186+
| Error | HTTP response code | Message
1187+
| ----- | ------------------------- | --------------
1188+
| 1000 | 404 Not found | Route not found
1189+
| 1001 | 404 Not found | Table not found
1190+
| 1002 | 422 Unprocessable entity | Argument count mismatch
1191+
| 1003 | 404 Not found | Record not found
1192+
| 1004 | 403 Forbidden | Origin is forbidden
1193+
| 1005 | 404 Not found | Column not found
1194+
| 1006 | 409 Conflict | Table already exists
1195+
| 1007 | 409 Conflict | Column already exists
1196+
| 1008 | 422 Unprocessable entity | Cannot read HTTP message
1197+
| 1009 | 409 Conflict | Duplicate key exception
1198+
| 1010 | 409 Conflict | Data integrity violation
1199+
| 1011 | 401 Unauthorized | Authentication required
1200+
| 1012 | 403 Forbidden | Authentication failed
1201+
| 1013 | 422 Unprocessable entity | Input validation failed
1202+
| 1014 | 403 Forbidden | Operation forbidden
1203+
| 1015 | 405 Method not allowed | Operation not supported
1204+
| 1016 | 403 Forbidden | Temporary or permanently blocked
1205+
| 1017 | 403 Forbidden | Bad or missing XSRF token
1206+
| 1018 | 403 Forbidden | Only AJAX requests allowed
1207+
| 1019 | 403 Forbidden | Pagination Forbidden
1208+
| 9999 | 500 Internal server error | Unknown error
12091209

12101210
The following JSON structure is used:
12111211

@@ -1240,6 +1240,7 @@ This runs the functional tests from the "tests" directory. It uses the database
12401240
database configuration (config) from the corresponding subdirectories.
12411241

12421242
## Nginx config example
1243+
12431244
```
12441245
server {
12451246
listen 80 default_server;

api.include.php

+4-3
Original file line numberDiff line numberDiff line change
@@ -4522,6 +4522,7 @@ public function read(ServerRequestInterface $request): ResponseInterface
45224522
use Tqdev\PhpCrudApi\Record\Document\ErrorDocument;
45234523
use Tqdev\PhpCrudApi\Record\ErrorCode;
45244524
use Tqdev\PhpCrudApi\ResponseFactory;
4525+
use Tqdev\PhpCrudApi\ResponseUtils;
45254526

45264527
class JsonResponder implements Responder
45274528
{
@@ -4558,20 +4559,20 @@ public function multi($results): ResponseInterface
45584559
$documents = array();
45594560
$errors = array();
45604561
$success = true;
4561-
foreach ($results as $i=>$result) {
4562+
foreach ($results as $i => $result) {
45624563
if ($result instanceof \Throwable) {
45634564
$documents[$i] = null;
45644565
$errors[$i] = ErrorDocument::fromException($result);
45654566
$success = false;
45664567
} else {
45674568
$documents[$i] = $result;
4568-
$errors[$i] = new ErrorDocument(new ErrorCode(0),'',null);
4569+
$errors[$i] = new ErrorDocument(new ErrorCode(0), '', null);
45694570
}
45704571
}
45714572
$status = $success ? ResponseFactory::OK : ResponseFactory::FAILED_DEPENDENCY;
45724573
$document = $success ? $documents : $errors;
45734574
$response = ResponseFactory::fromObject($status, $document);
4574-
foreach ($results as $i=>$result) {
4575+
foreach ($results as $i => $result) {
45754576
if ($result instanceof \Throwable) {
45764577
if ($this->debug) {
45774578
$response = ResponseUtils::addExceptionHeaders($response, $result);

api.php

+4-3
Original file line numberDiff line numberDiff line change
@@ -4522,6 +4522,7 @@ public function read(ServerRequestInterface $request): ResponseInterface
45224522
use Tqdev\PhpCrudApi\Record\Document\ErrorDocument;
45234523
use Tqdev\PhpCrudApi\Record\ErrorCode;
45244524
use Tqdev\PhpCrudApi\ResponseFactory;
4525+
use Tqdev\PhpCrudApi\ResponseUtils;
45254526

45264527
class JsonResponder implements Responder
45274528
{
@@ -4558,20 +4559,20 @@ public function multi($results): ResponseInterface
45584559
$documents = array();
45594560
$errors = array();
45604561
$success = true;
4561-
foreach ($results as $i=>$result) {
4562+
foreach ($results as $i => $result) {
45624563
if ($result instanceof \Throwable) {
45634564
$documents[$i] = null;
45644565
$errors[$i] = ErrorDocument::fromException($result);
45654566
$success = false;
45664567
} else {
45674568
$documents[$i] = $result;
4568-
$errors[$i] = new ErrorDocument(new ErrorCode(0),'',null);
4569+
$errors[$i] = new ErrorDocument(new ErrorCode(0), '', null);
45694570
}
45704571
}
45714572
$status = $success ? ResponseFactory::OK : ResponseFactory::FAILED_DEPENDENCY;
45724573
$document = $success ? $documents : $errors;
45734574
$response = ResponseFactory::fromObject($status, $document);
4574-
foreach ($results as $i=>$result) {
4575+
foreach ($results as $i => $result) {
45754576
if ($result instanceof \Throwable) {
45764577
if ($this->debug) {
45774578
$response = ResponseUtils::addExceptionHeaders($response, $result);

src/Tqdev/PhpCrudApi/Controller/JsonResponder.php

+4-3
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
use Tqdev\PhpCrudApi\Record\Document\ErrorDocument;
77
use Tqdev\PhpCrudApi\Record\ErrorCode;
88
use Tqdev\PhpCrudApi\ResponseFactory;
9+
use Tqdev\PhpCrudApi\ResponseUtils;
910

1011
class JsonResponder implements Responder
1112
{
@@ -42,20 +43,20 @@ public function multi($results): ResponseInterface
4243
$documents = array();
4344
$errors = array();
4445
$success = true;
45-
foreach ($results as $i=>$result) {
46+
foreach ($results as $i => $result) {
4647
if ($result instanceof \Throwable) {
4748
$documents[$i] = null;
4849
$errors[$i] = ErrorDocument::fromException($result);
4950
$success = false;
5051
} else {
5152
$documents[$i] = $result;
52-
$errors[$i] = new ErrorDocument(new ErrorCode(0),'',null);
53+
$errors[$i] = new ErrorDocument(new ErrorCode(0), '', null);
5354
}
5455
}
5556
$status = $success ? ResponseFactory::OK : ResponseFactory::FAILED_DEPENDENCY;
5657
$document = $success ? $documents : $errors;
5758
$response = ResponseFactory::fromObject($status, $document);
58-
foreach ($results as $i=>$result) {
59+
foreach ($results as $i => $result) {
5960
if ($result instanceof \Throwable) {
6061
if ($this->debug) {
6162
$response = ResponseUtils::addExceptionHeaders($response, $result);

0 commit comments

Comments
 (0)