Advertisement
Guest User

Untitled

a guest
Jan 16th, 2018
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.47 KB | None | 0 0
  1. <?php
  2.  
  3. namespace app\controllers;
  4.  
  5. use Yii;
  6. use yii\filters\AccessControl;
  7. use yii\web\Controller;
  8. use yii\web\Response;
  9. use yii\filters\VerbFilter;
  10. use app\models\LoginForm;
  11. use app\models\ContactForm;
  12.  
  13. class AdminController extends Controller
  14. {
  15. /**
  16. * @inheritdoc
  17. */
  18. public function behaviors()
  19. {
  20. return [
  21. 'access' => [
  22. 'class' => \yii\filters\AccessControl::className(),
  23. 'rules' => [
  24. [
  25. 'actions' => ['login', 'error'],
  26. 'allow' => true,
  27. ],
  28. [
  29. 'actions' => ['logout', 'index'],
  30. 'allow' => true,
  31. 'roles' => ['@'],
  32. ],
  33. [
  34. 'allow' => !Yii::$app->user->isGuest && Yii::$app->user->identity->isAdmin(),
  35. 'actions' => ['about'],
  36. ],
  37. ],
  38. ],
  39. 'verbs' => [
  40. 'class' => VerbFilter::className(),
  41. 'actions' => [
  42. 'logout' => ['post'],
  43. ],
  44. ],
  45. ];
  46. }
  47.  
  48. /**
  49. * Displays homepage.
  50. *
  51. * @return string
  52. */
  53. public function actionIndex()
  54. {
  55. return $this->goHome();
  56. }
  57.  
  58. /**
  59. * Displays about page.
  60. *
  61. * @return string
  62. */
  63. public function actionAbout()
  64. {
  65. return $this->render('about');
  66. }
  67.  
  68.  
  69. }
  70. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement