From 6e8dbd3ae14e3d8ce8d08b1153d069d32f232ddc Mon Sep 17 00:00:00 2001 From: David Grudl Date: Wed, 30 Sep 2015 01:13:31 +0200 Subject: [PATCH 1/4] added CallbackResponse --- .../Responses/CallbackResponse.php | 37 +++++++++++++++++++ tests/Application/CallbackResponse.phpt | 21 +++++++++++ 2 files changed, 58 insertions(+) create mode 100644 src/Application/Responses/CallbackResponse.php create mode 100644 tests/Application/CallbackResponse.phpt diff --git a/src/Application/Responses/CallbackResponse.php b/src/Application/Responses/CallbackResponse.php new file mode 100644 index 000000000..90d1380e8 --- /dev/null +++ b/src/Application/Responses/CallbackResponse.php @@ -0,0 +1,37 @@ +callback = $callback; + } + + + /** + * Sends response to output. + * @return void + */ + public function send(Nette\Http\IRequest $httpRequest, Nette\Http\IResponse $httpResponse) + { + call_user_func($this->callback, $httpRequest, $httpResponse); + } + +} diff --git a/tests/Application/CallbackResponse.phpt b/tests/Application/CallbackResponse.phpt new file mode 100644 index 000000000..83ac423f8 --- /dev/null +++ b/tests/Application/CallbackResponse.phpt @@ -0,0 +1,21 @@ +send(new Http\Request(new Http\UrlScript), new Http\Response); + Assert::true($ok); +}); From 8b0111a94404402b7cef4a8190fb2fb65540de78 Mon Sep 17 00:00:00 2001 From: David Grudl Date: Wed, 30 Sep 2015 02:22:56 +0200 Subject: [PATCH 2/4] ErrorPresenter: returns CallbackResponse --- src/Application/ErrorPresenter.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Application/ErrorPresenter.php b/src/Application/ErrorPresenter.php index a19d204e3..9553cce49 100644 --- a/src/Application/ErrorPresenter.php +++ b/src/Application/ErrorPresenter.php @@ -41,9 +41,9 @@ public function run(Application\Request $request) $this->logger->log($e, ILogger::EXCEPTION); } } - ob_start(); - require __DIR__ . '/templates/error.phtml'; - return new Application\Responses\TextResponse(ob_get_clean()); + return new Application\Responses\CallbackResponse(function () use ($code) { + require __DIR__ . '/templates/error.phtml'; + }); } } From 93c8707c4e3b675280401675f65338dfa8f390e3 Mon Sep 17 00:00:00 2001 From: Ondrej Nespor Date: Tue, 22 Sep 2015 13:05:08 +0200 Subject: [PATCH 3/4] Interface for route lists --- src/Application/IRouteList.php | 23 +++++++++++++++++++++++ src/Application/Routers/RouteList.php | 2 +- 2 files changed, 24 insertions(+), 1 deletion(-) create mode 100644 src/Application/IRouteList.php diff --git a/src/Application/IRouteList.php b/src/Application/IRouteList.php new file mode 100644 index 000000000..e7a771aa9 --- /dev/null +++ b/src/Application/IRouteList.php @@ -0,0 +1,23 @@ + Date: Wed, 30 Sep 2015 10:02:02 +0200 Subject: [PATCH 4/4] Router panel support for any route list --- src/Bridges/ApplicationTracy/RoutingPanel.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Bridges/ApplicationTracy/RoutingPanel.php b/src/Bridges/ApplicationTracy/RoutingPanel.php index 83468ef5a..9753ea564 100644 --- a/src/Bridges/ApplicationTracy/RoutingPanel.php +++ b/src/Bridges/ApplicationTracy/RoutingPanel.php @@ -96,7 +96,7 @@ public function getPanel() */ private function analyse($router, $module = '') { - if ($router instanceof Routers\RouteList) { + if ($router instanceof Nette\Application\IRouteList) { foreach ($router as $subRouter) { $this->analyse($subRouter, $module . $router->getModule()); }