|
|
@@ -14,6 +14,7 @@ class Minz_Dispatcher {
|
|
|
|
|
|
/* singleton */
|
|
|
private static $instance = null;
|
|
|
+ private static $needsReset;
|
|
|
|
|
|
private $router;
|
|
|
private $controller;
|
|
|
@@ -40,44 +41,36 @@ class Minz_Dispatcher {
|
|
|
* Remplit le body de Response à partir de la Vue
|
|
|
* @exception Minz_Exception
|
|
|
*/
|
|
|
- public function run ($ob = true) {
|
|
|
- // Le ob_start est dupliqué : sans ça il y a un bug sous Firefox
|
|
|
- // ici on l'appelle avec 'ob_gzhandler', après sans.
|
|
|
- // Vraisemblablement la compression fonctionne mais c'est sale
|
|
|
- // J'ignore les effets de bord :(
|
|
|
- if ($ob) {
|
|
|
- ob_start ('ob_gzhandler');
|
|
|
- }
|
|
|
-
|
|
|
- $text = ''; //TODO: Clean this code
|
|
|
- while (Minz_Request::$reseted) {
|
|
|
- Minz_Request::$reseted = false;
|
|
|
+ public function run () {
|
|
|
+ do {
|
|
|
+ self::$needsReset = false;
|
|
|
|
|
|
try {
|
|
|
$this->createController ('FreshRSS_' . Minz_Request::controllerName () . '_Controller');
|
|
|
$this->controller->init ();
|
|
|
$this->controller->firstAction ();
|
|
|
- $this->launchAction (
|
|
|
- Minz_Request::actionName ()
|
|
|
- . 'Action'
|
|
|
- );
|
|
|
+ if (!self::$needsReset) {
|
|
|
+ $this->launchAction (
|
|
|
+ Minz_Request::actionName ()
|
|
|
+ . 'Action'
|
|
|
+ );
|
|
|
+ }
|
|
|
$this->controller->lastAction ();
|
|
|
|
|
|
- if (!Minz_Request::$reseted) {
|
|
|
- if ($ob) {
|
|
|
- ob_start ();
|
|
|
- }
|
|
|
- $this->controller->view ()->build ();
|
|
|
- if ($ob) {
|
|
|
- $text = ob_get_clean();
|
|
|
- }
|
|
|
+ if (!self::$needsReset) {
|
|
|
+ echo $this->controller->view ()->build ();
|
|
|
}
|
|
|
} catch (Minz_Exception $e) {
|
|
|
throw $e;
|
|
|
}
|
|
|
- }
|
|
|
+ } while (self::$needsReset);
|
|
|
+ }
|
|
|
|
|
|
- Minz_Response::setBody ($text);
|
|
|
+ /**
|
|
|
+ * Informe le contrôleur qu'il doit recommancer car la requête a été modifiée
|
|
|
+ */
|
|
|
+ public static function reset() {
|
|
|
+ self::$needsReset = true;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -114,21 +107,19 @@ class Minz_Dispatcher {
|
|
|
* le controller
|
|
|
*/
|
|
|
private function launchAction ($action_name) {
|
|
|
- if (!Minz_Request::$reseted) {
|
|
|
- if (!is_callable (array (
|
|
|
- $this->controller,
|
|
|
- $action_name
|
|
|
- ))) {
|
|
|
- throw new Minz_ActionException (
|
|
|
- get_class ($this->controller),
|
|
|
- $action_name,
|
|
|
- Minz_Exception::ERROR
|
|
|
- );
|
|
|
- }
|
|
|
- call_user_func (array (
|
|
|
- $this->controller,
|
|
|
- $action_name
|
|
|
- ));
|
|
|
+ if (!is_callable (array (
|
|
|
+ $this->controller,
|
|
|
+ $action_name
|
|
|
+ ))) {
|
|
|
+ throw new Minz_ActionException (
|
|
|
+ get_class ($this->controller),
|
|
|
+ $action_name,
|
|
|
+ Minz_Exception::ERROR
|
|
|
+ );
|
|
|
}
|
|
|
+ call_user_func (array (
|
|
|
+ $this->controller,
|
|
|
+ $action_name
|
|
|
+ ));
|
|
|
}
|
|
|
}
|