From cba8ec73104902128248257250f2e84688838f2b Mon Sep 17 00:00:00 2001 From: Carsten Brandt Date: Sun, 13 Oct 2013 15:41:14 +0200 Subject: [PATCH] fixes issue with debugmodule initializing view component too early fixes #929 --- framework/yii/debug/Module.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/framework/yii/debug/Module.php b/framework/yii/debug/Module.php index dd027a7..9550b57 100644 --- a/framework/yii/debug/Module.php +++ b/framework/yii/debug/Module.php @@ -8,6 +8,7 @@ namespace yii\debug; use Yii; +use yii\base\Application; use yii\base\View; use yii\web\HttpException; @@ -55,7 +56,11 @@ class Module extends \yii\base\Module parent::init(); $this->dataPath = Yii::getAlias($this->dataPath); $this->logTarget = Yii::$app->getLog()->targets['debug'] = new LogTarget($this); - Yii::$app->getView()->on(View::EVENT_END_BODY, array($this, 'renderToolbar')); + // do not initialize view component before application is ready (needed when debug in preload) + $module = $this; + Yii::$app->on(Application::EVENT_BEFORE_ACTION, function() use ($module) { + Yii::$app->getView()->on(View::EVENT_END_BODY, array($module, 'renderToolbar')); + }); foreach (array_merge($this->corePanels(), $this->panels) as $id => $config) { $config['module'] = $this;