|
|
@ -1,5 +1,6 @@
|
|
|
|
<?php
|
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
use ExceptionHandle\HttpNotFoundError;
|
|
|
|
use ExceptionHandle\TypeErrorMethod;
|
|
|
|
use ExceptionHandle\TypeErrorMethod;
|
|
|
|
use Psr\Http\Message\ResponseInterface as Response;
|
|
|
|
use Psr\Http\Message\ResponseInterface as Response;
|
|
|
|
use Psr\Http\Message\ServerRequestInterface as Request;
|
|
|
|
use Psr\Http\Message\ServerRequestInterface as Request;
|
|
|
@ -23,7 +24,7 @@ $app->addRoutingMiddleware();
|
|
|
|
* @param bool $logErrors -> Parameter is passed to the default ErrorHandler
|
|
|
|
* @param bool $logErrors -> Parameter is passed to the default ErrorHandler
|
|
|
|
* @param bool $logErrorDetails -> Display error details in error log
|
|
|
|
* @param bool $logErrorDetails -> Display error details in error log
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
$errorMiddleware = $app->addErrorMiddleware(true, true, true);
|
|
|
|
$errorMiddleware = $app->addErrorMiddleware(true, true, false);
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* Add a route for the API
|
|
|
|
* Add a route for the API
|
|
|
@ -37,11 +38,16 @@ $app->get('/', function (Request $request, Response $response) {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
unset($parameters['method']);
|
|
|
|
unset($parameters['method']);
|
|
|
|
$listGateway = array("\\Gateway\\GatewayForm", "\\Gateway\\GatewayKeyword", "\\Gateway\\GatewayQuestion");
|
|
|
|
$listGateway = array("\\Gateway\\GatewayForm", "\\Gateway\\GatewayKeyword", "\\Gateway\\GatewayQuestion");
|
|
|
|
|
|
|
|
$ok = false;
|
|
|
|
foreach ($listGateway as $gateway){
|
|
|
|
foreach ($listGateway as $gateway){
|
|
|
|
if (method_exists($gateway, $method)) {
|
|
|
|
if (method_exists($gateway, $method)) {
|
|
|
|
|
|
|
|
$ok = true;
|
|
|
|
$response->getBody()->write(json_encode((new $gateway)->$method($parameters)));
|
|
|
|
$response->getBody()->write(json_encode((new $gateway)->$method($parameters)));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!$ok){
|
|
|
|
|
|
|
|
throw new HttpNotFoundError($request);
|
|
|
|
|
|
|
|
}
|
|
|
|
$temp = array(0 => array("id" => "1",
|
|
|
|
$temp = array(0 => array("id" => "1",
|
|
|
|
"0" => "1",
|
|
|
|
"0" => "1",
|
|
|
|
"title" => "Votre avis nous intéresse !",
|
|
|
|
"title" => "Votre avis nous intéresse !",
|
|
|
|