From 6a407fc87a8b094e8129a0c8ad41c1e7ec5bffa0 Mon Sep 17 00:00:00 2001 From: Marcin Kurczewski Date: Wed, 5 Feb 2014 08:22:26 +0100 Subject: [PATCH] Fixed #73 --- src/Bootstrap.php | 39 +++++++++++++++++++++++++++------------ 1 file changed, 27 insertions(+), 12 deletions(-) diff --git a/src/Bootstrap.php b/src/Bootstrap.php index cef2078b..ece46820 100644 --- a/src/Bootstrap.php +++ b/src/Bootstrap.php @@ -1,6 +1,28 @@ renderFile($this->context->layoutName); + }; + } + + if ($this->context->layoutName == 'layout-normal') + { + ob_start(['LayoutHelper', 'transformHtml']); + $callback(); + ob_end_flush(); + } + else + { + $callback(); + } + } + public function workWrapper($workCallback) { $this->config->chibi->baseUrl = 'http://' . rtrim($_SERVER['HTTP_HOST'], '/') . '/'; @@ -21,33 +43,26 @@ class Bootstrap if (empty($this->context->route)) { $this->context->viewName = 'error-404'; - (new \Chibi\View())->renderFile($this->context->layoutName); + $this->render(); return; } try { - if ($this->context->layoutName == 'layout-normal') - { - ob_start(['LayoutHelper', 'transformHtml']); - $workCallback(); - ob_end_flush(); - } - else - $workCallback(); + $this->render($workCallback); } catch (\Chibi\MissingViewFileException $e) { $this->context->json = true; $this->context->layoutName = 'layout-json'; - (new \Chibi\View())->renderFile($this->context->layoutName); + $this->render(); } catch (SimpleException $e) { StatusHelper::failure(rtrim($e->getMessage(), '.') . '.'); if (!$this->context->handleExceptions) $this->context->viewName = 'message'; - (new \Chibi\View())->renderFile($this->context->layoutName); + $this->render(); } catch (Exception $e) { @@ -55,7 +70,7 @@ class Bootstrap $this->context->transport->exception = $e; $this->context->transport->queries = Database::getLogs(); $this->context->viewName = 'error-exception'; - (new \Chibi\View())->renderFile($this->context->layoutName); + $this->render(); } AuthController::observeWorkFinish();