From 663d3fedc8c406e31e5cf535e4ccef2dc29857cb Mon Sep 17 00:00:00 2001 From: Alexander Makarov Date: Wed, 2 Apr 2014 12:42:04 +0400 Subject: [PATCH] Added defaultView to ViewAction --- framework/web/ViewAction.php | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/framework/web/ViewAction.php b/framework/web/ViewAction.php index 6b8dbc5..256aa56 100644 --- a/framework/web/ViewAction.php +++ b/framework/web/ViewAction.php @@ -36,6 +36,14 @@ class ViewAction extends Action public $viewParam = 'view'; /** + * @var string the name of the default view when [[\yii\web\ViewAction::$viewParam]] GET parameter is not provided + * by user. Defaults to 'index'. This should be in the format of 'path/to/view', similar to that given in the + * GET parameter. + * @see \yii\web\ViewAction::$viewPrefix + */ + public $defaultView = 'index'; + + /** * @var string a string to be prefixed to the user-specified view name to form a complete view name. * For example, if a user requests for `tutorial/chap1`, the corresponding view name will * be `pages/tutorial/chap1`, assuming the prefix is `pages`. @@ -111,7 +119,7 @@ class ViewAction extends Action */ protected function resolveViewName() { - $viewName = Yii::$app->request->get($this->viewParam); + $viewName = Yii::$app->request->get($this->viewParam, $this->defaultView); if (!is_string($viewName) || !preg_match('/^\w[\w\/\-\.]*$/', $viewName)) { if (YII_DEBUG) {