From a8053352f2caf85829c2121b38416145779c5abc Mon Sep 17 00:00:00 2001 From: Qiang Xue Date: Thu, 13 Jun 2013 23:39:18 -0400 Subject: [PATCH] Refactored the way of sending response in controller actions. --- controllers/SiteController.php | 16 ++++++++-------- yii | 2 +- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/controllers/SiteController.php b/controllers/SiteController.php index ff3b8b4..d79b728 100644 --- a/controllers/SiteController.php +++ b/controllers/SiteController.php @@ -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'); } } diff --git a/yii b/yii index 0793523..be27cac 100755 --- a/yii +++ b/yii @@ -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();