Refactored the way of sending response in controller actions.
This commit is contained in:
parent
f026d360de
commit
a8053352f2
@ -20,16 +20,16 @@ class SiteController extends Controller
|
|||||||
|
|
||||||
public function actionIndex()
|
public function actionIndex()
|
||||||
{
|
{
|
||||||
echo $this->render('index');
|
return $this->render('index');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function actionLogin()
|
public function actionLogin()
|
||||||
{
|
{
|
||||||
$model = new LoginForm();
|
$model = new LoginForm();
|
||||||
if ($this->populate($_POST, $model) && $model->login()) {
|
if ($this->populate($_POST, $model) && $model->login()) {
|
||||||
Yii::$app->response->redirect(array('site/index'));
|
return Yii::$app->response->redirect(array('site/index'));
|
||||||
} else {
|
} else {
|
||||||
echo $this->render('login', array(
|
return $this->render('login', array(
|
||||||
'model' => $model,
|
'model' => $model,
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
@ -37,8 +37,8 @@ class SiteController extends Controller
|
|||||||
|
|
||||||
public function actionLogout()
|
public function actionLogout()
|
||||||
{
|
{
|
||||||
Yii::$app->getUser()->logout();
|
Yii::$app->user->logout();
|
||||||
Yii::$app->getResponse()->redirect(array('site/index'));
|
return Yii::$app->response->redirect(array('site/index'));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function actionContact()
|
public function actionContact()
|
||||||
@ -46,9 +46,9 @@ class SiteController extends Controller
|
|||||||
$model = new ContactForm;
|
$model = new ContactForm;
|
||||||
if ($this->populate($_POST, $model) && $model->contact(Yii::$app->params['adminEmail'])) {
|
if ($this->populate($_POST, $model) && $model->contact(Yii::$app->params['adminEmail'])) {
|
||||||
Yii::$app->session->setFlash('contactFormSubmitted');
|
Yii::$app->session->setFlash('contactFormSubmitted');
|
||||||
Yii::$app->response->refresh();
|
return Yii::$app->response->refresh();
|
||||||
} else {
|
} else {
|
||||||
echo $this->render('contact', array(
|
return $this->render('contact', array(
|
||||||
'model' => $model,
|
'model' => $model,
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
@ -56,6 +56,6 @@ class SiteController extends Controller
|
|||||||
|
|
||||||
public function actionAbout()
|
public function actionAbout()
|
||||||
{
|
{
|
||||||
echo $this->render('about');
|
return $this->render('about');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
2
yii
2
yii
@ -19,4 +19,4 @@ require(__DIR__ . '/vendor/autoload.php');
|
|||||||
$config = require(__DIR__ . '/config/console.php');
|
$config = require(__DIR__ . '/config/console.php');
|
||||||
|
|
||||||
$application = new yii\console\Application($config);
|
$application = new yii\console\Application($config);
|
||||||
$application->run();
|
return $application->run();
|
||||||
|
Loading…
Reference in New Issue
Block a user