diff options
| author | 2014-03-24 20:55:18 +0100 | |
|---|---|---|
| committer | 2014-03-24 20:55:18 +0100 | |
| commit | c8aa451c768a3d4dfce3d19648f3c8420dedb74c (patch) | |
| tree | 9d25dc6fdebd91ab80699f0b8d7fb91788a1ca4b /lib/Minz/FrontController.php | |
| parent | fd829d75676a07a13a635db037efa92e364026a7 (diff) | |
Minz: remove url_rewriting
As suggested
https://github.com/marienfressinaud/FreshRSS/issues/163#issuecomment-38478669
At the same time, removes a bunch of (almost) dead code such as
Minz_Router (the few remaining lines being moved to Minz_FrontController
to avoid a class)
Contributes to https://github.com/marienfressinaud/FreshRSS/issues/303
Diffstat (limited to 'lib/Minz/FrontController.php')
| -rw-r--r-- | lib/Minz/FrontController.php | 43 |
1 files changed, 32 insertions, 11 deletions
diff --git a/lib/Minz/FrontController.php b/lib/Minz/FrontController.php index 3e50db1cf..f13882801 100644 --- a/lib/Minz/FrontController.php +++ b/lib/Minz/FrontController.php @@ -24,11 +24,10 @@ */ class Minz_FrontController { protected $dispatcher; - protected $router; /** * Constructeur - * Initialise le router et le dispatcher + * Initialise le dispatcher, met à jour la Request */ public function __construct () { if (LOG_PATH === false) { @@ -40,24 +39,46 @@ class Minz_FrontController { Minz_Request::init (); - $this->router = new Minz_Router (); - $this->router->init (); - } catch (Minz_RouteNotFoundException $e) { - Minz_Log::record ($e->getMessage (), Minz_Log::ERROR); - Minz_Error::error ( - 404, - array ('error' => array ($e->getMessage ())) + $url = $this->buildUrl(); + $url['params'] = array_merge ( + $url['params'], + Minz_Request::fetchPOST () ); + Minz_Request::forward ($url); } catch (Minz_Exception $e) { Minz_Log::record ($e->getMessage (), Minz_Log::ERROR); $this->killApp ($e->getMessage ()); } - $this->dispatcher = Minz_Dispatcher::getInstance ($this->router); + $this->dispatcher = Minz_Dispatcher::getInstance(); + } + + /** + * Retourne un tableau représentant l'url passée par la barre d'adresses + * @return tableau représentant l'url + */ + private function buildUrl() { + $url = array (); + + $url['c'] = Minz_Request::fetchGET ( + 'c', + Minz_Request::defaultControllerName () + ); + $url['a'] = Minz_Request::fetchGET ( + 'a', + Minz_Request::defaultActionName () + ); + $url['params'] = Minz_Request::fetchGET (); + + // post-traitement + unset ($url['params']['c']); + unset ($url['params']['a']); + + return $url; } /** - * Démarre l'application (lance le dispatcher et renvoie la réponse + * Démarre l'application (lance le dispatcher et renvoie la réponse) */ public function run () { try { |
