|
|
|
@ -25,6 +25,7 @@ class Control {
|
|
|
|
|
if (!$payload_obj instanceof \stdClass) {
|
|
|
|
|
$fail = new ValidationFail("bad-payload", "request body is not a valid json object");
|
|
|
|
|
return $errorFactory->apply([$fail]);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
$payload = get_object_vars($payload_obj);
|
|
|
|
|
return self::runCheckedFrom($payload, $schema, $run, $errorFactory);
|
|
|
|
@ -36,7 +37,6 @@ class Control {
|
|
|
|
|
* @param array<string, Validator[]> $schema an array of `fieldName => DefaultValidators` which represents the request object schema
|
|
|
|
|
* @param callable(HttpRequest): HttpResponse $run the callback to run if the request is valid according to the given schema.
|
|
|
|
|
* The callback must accept an HttpRequest, and return an HttpResponse object.
|
|
|
|
|
<<<<<<< HEAD:src/Core/Control.php
|
|
|
|
|
* @param ControlSchemaErrorResponseFactory $errorFactory an error factory to use if the request does not validate the required schema
|
|
|
|
|
* @return HttpResponse
|
|
|
|
|
*/
|
|
|
|
@ -46,6 +46,7 @@ class Control {
|
|
|
|
|
|
|
|
|
|
if (!empty($fails)) {
|
|
|
|
|
return $errorFactory->apply($fails);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return call_user_func_array($run, [$request]);
|
|
|
|
|