Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- namespace app\controllers;
- use Yii;
- use yii\filters\AccessControl;
- use yii\web\Controller;
- use yii\web\Response;
- use yii\filters\VerbFilter;
- use app\models\LoginForm;
- use app\models\ContactForm;
- class AdminController extends Controller
- {
- /**
- * @inheritdoc
- */
- public function behaviors()
- {
- return [
- 'access' => [
- 'class' => \yii\filters\AccessControl::className(),
- 'rules' => [
- [
- 'actions' => ['login', 'error'],
- 'allow' => true,
- ],
- [
- 'actions' => ['logout', 'index'],
- 'allow' => true,
- 'roles' => ['@'],
- ],
- [
- 'allow' => !Yii::$app->user->isGuest && Yii::$app->user->identity->isAdmin(),
- 'actions' => ['about'],
- ],
- ],
- ],
- 'verbs' => [
- 'class' => VerbFilter::className(),
- 'actions' => [
- 'logout' => ['post'],
- ],
- ],
- ];
- }
- /**
- * Displays homepage.
- *
- * @return string
- */
- public function actionIndex()
- {
- return $this->goHome();
- }
- /**
- * Displays about page.
- *
- * @return string
- */
- public function actionAbout()
- {
- return $this->render('about');
- }
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement