Refactored the way of sending response in controller actions.

This commit is contained in:
Qiang Xue 2013-06-13 23:39:18 -04:00
parent f026d360de
commit a8053352f2
2 changed files with 9 additions and 9 deletions

View File

@ -20,16 +20,16 @@ class SiteController extends Controller
public function actionIndex()
{
echo $this->render('index');
return $this->render('index');
}
public function actionLogin()
{
$model = new LoginForm();
if ($this->populate($_POST, $model) && $model->login()) {
Yii::$app->response->redirect(array('site/index'));
return Yii::$app->response->redirect(array('site/index'));
} else {
echo $this->render('login', array(
return $this->render('login', array(
'model' => $model,
));
}
@ -37,8 +37,8 @@ class SiteController extends Controller
public function actionLogout()
{
Yii::$app->getUser()->logout();
Yii::$app->getResponse()->redirect(array('site/index'));
Yii::$app->user->logout();
return Yii::$app->response->redirect(array('site/index'));
}
public function actionContact()
@ -46,9 +46,9 @@ class SiteController extends Controller
$model = new ContactForm;
if ($this->populate($_POST, $model) && $model->contact(Yii::$app->params['adminEmail'])) {
Yii::$app->session->setFlash('contactFormSubmitted');
Yii::$app->response->refresh();
return Yii::$app->response->refresh();
} else {
echo $this->render('contact', array(
return $this->render('contact', array(
'model' => $model,
));
}
@ -56,6 +56,6 @@ class SiteController extends Controller
public function actionAbout()
{
echo $this->render('about');
return $this->render('about');
}
}

2
yii
View File

@ -19,4 +19,4 @@ require(__DIR__ . '/vendor/autoload.php');
$config = require(__DIR__ . '/config/console.php');
$application = new yii\console\Application($config);
$application->run();
return $application->run();