Merge pull request #38 from ThomasRubini/kernel_get

This commit is contained in:
Thomas Rubini 2023-01-20 10:52:14 +01:00 committed by GitHub
commit ed0d34d0b5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 4 deletions

View File

@ -8,7 +8,7 @@ final class controller
private $_A_postParams; private $_A_postParams;
public function __construct ($S_url, $A_postParams) public function __construct ($S_url, $A_postParams, $A_getParams)
{ {
// Remove the trailing slash // Remove the trailing slash
if ('/' == substr($S_url, -1, 1)) { if ('/' == substr($S_url, -1, 1)) {
@ -43,6 +43,8 @@ final class controller
$this->_A_postParams = $A_postParams; $this->_A_postParams = $A_postParams;
$this->_A_getParams = $A_getParams;
} }
@ -60,8 +62,11 @@ final class controller
} }
$B_called = call_user_func_array(array(new $this->_A_urlParts['controller'], $B_called = call_user_func_array(array(
$this->_A_urlParts['action']), array($this->_A_urlParams, $this->_A_postParams )); new $this->_A_urlParts['controller'],
$this->_A_urlParts['action']),
array($this->_A_urlParams, $this->_A_postParams, $this->_A_getParams)
);
if (false === $B_called) { if (false === $B_called) {
throw new ControllerException("Action " . $this->_A_urlParts['action'] . throw new ControllerException("Action " . $this->_A_urlParts['action'] .

View File

@ -9,12 +9,15 @@
$S_url = isset($_GET['url']) ? $_GET['url'] : null; $S_url = isset($_GET['url']) ? $_GET['url'] : null;
$A_postParams = isset($_POST) ? $_POST : null; $A_postParams = isset($_POST) ? $_POST : null;
$A_getParams = isset($_GET) ? $_GET : null;
unset($A_getParams["url"]);
View::openBuffer(); View::openBuffer();
try try
{ {
$O_controller = new Controller($S_url, $A_postParams); $O_controller = new Controller($S_url, $A_postParams, $A_getParams);
$O_controller->execute(); $O_controller->execute();
} }
catch (ControleurException $O_exception) catch (ControleurException $O_exception)