Class app\controllers\SiteController

Inheritanceapp\controllers\SiteController » yii\web\Controller
Source Code https://github.com/yiisoft/yii2-app-basic/blob/master/controllers/SiteController.php

Method Details

Hide inherited methods

actionAbout() public method

Displays about page.

public string actionAbout ( )

                public function actionAbout()
{
    return $this->render('about');
}

            
actionContact() public method

Displays contact page.

public \yii\web\Response|string actionContact ( )

                public function actionContact()
{
    $model = new ContactForm();
    if ($model->load(Yii::$app->request->post()) && $model->contact(Yii::$app->params['adminEmail'])) {
        Yii::$app->session->setFlash('contactFormSubmitted');
        return $this->refresh();
    }
    return $this->render('contact', [
        'model' => $model,
    ]);
}

            
actionIndex() public method

Displays homepage.

public string actionIndex ( )

                public function actionIndex()
{
    return $this->render('index');
}

            
actionLogin() public method

Login action.

public \yii\web\Response|string actionLogin ( )

                public function actionLogin()
{
    if (!Yii::$app->user->isGuest) {
        return $this->goHome();
    }
    $model = new LoginForm();
    if ($model->load(Yii::$app->request->post()) && $model->login()) {
        return $this->goBack();
    }
    $model->password = '';
    return $this->render('login', [
        'model' => $model,
    ]);
}

            
actionLogout() public method

Logout action.

public \yii\web\Response actionLogout ( )

                public function actionLogout()
{
    Yii::$app->user->logout();
    return $this->goHome();
}

            
actions() public method

public void actions ( )

                public function actions()
{
    return [
        'error' => [
            'class' => 'yii\web\ErrorAction',
        ],
        'captcha' => [
            'class' => 'yii\captcha\CaptchaAction',
            'fixedVerifyCode' => YII_ENV_TEST ? 'testme' : null,
        ],
    ];
}

            
behaviors() public method

public void behaviors ( )

                public function behaviors()
{
    return [
        'access' => [
            'class' => AccessControl::class,
            'only' => ['logout'],
            'rules' => [
                [
                    'actions' => ['logout'],
                    'allow' => true,
                    'roles' => ['@'],
                ],
            ],
        ],
        'verbs' => [
            'class' => VerbFilter::class,
            'actions' => [
                'logout' => ['post'],
            ],
        ],
    ];
}