| Current Path : /var/www/html/dynaweb.blunetdev.com/frontend/controllers/ |
| Current File : /var/www/html/dynaweb.blunetdev.com/frontend/controllers/SiteController.php |
<?php
namespace frontend\controllers;
use Yii;
use yii\filters\AccessControl;
use yii\filters\VerbFilter;
use yii\web\Controller;
/**
* Site controller
*/
class SiteController extends Controller
{
/**
* {@inheritDoc}
* @see \yii\web\Controller::beforeAction()
*/
public function beforeAction($action)
{
// $this->layout = 'main_default';
// TODO Auto-generated method stub
return parent::beforeAction($action);
}
/**
* @inheritdoc
*/
public function behaviors()
{
return [
'access' => [
'class' => AccessControl::className(),
'only' => ['logout', 'signup', 'error'],
'rules' => [
[
'actions' => ['signup','error'],
'allow' => true,
'roles' => ['?'],
],
[
'actions' => ['logout','error'],
'allow' => true,
'roles' => ['@'],
],
],
],
'verbs' => [
'class' => VerbFilter::className(),
],
];
}
/**
* @inheritdoc
*/
public function actions()
{
return [
'error' => [
'class' => 'yii\web\ErrorAction',
],
'captcha' => [
'class' => 'yii\captcha\CaptchaAction',
'fixedVerifyCode' => YII_ENV_TEST ? 'testme' : null,
],
];
}
/**
* Displays homepage.
*
* @return mixed
*/
public function actionIndex()
{
return $this->render('index');
}
public function actionStub() {
//throw new \Exception('Error');
return $this->asJson(['success' => 'true']);
}
/**
* Logs out the current user.
*
* @return mixed
*/
public function actionLogout()
{
Yii::$app->user->logout();
return $this->goHome();
}
public function actionError()
{
$exception = Yii::$app->errorHandler->exception;
if ($exception !== null) {
return $exception->getMessage();
}
}
public function actionTest() {
echo '-----TEST GATOR-----';die;
}
}