You can not select more than 25 topics
			Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
		
		
		
		
			
				
					78 lines
				
				1.6 KiB
			
		
		
			
		
	
	
					78 lines
				
				1.6 KiB
			| 
								 
											8 years ago
										 
									 | 
							
								<?php
							 | 
						||
| 
								 | 
							
								namespace backend\controllers;
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								use Yii;
							 | 
						||
| 
								 | 
							
								use yii\web\Controller;
							 | 
						||
| 
								 | 
							
								use yii\filters\VerbFilter;
							 | 
						||
| 
								 | 
							
								use yii\filters\AccessControl;
							 | 
						||
| 
								 | 
							
								use common\models\LoginForm;
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/**
							 | 
						||
| 
								 | 
							
								 * Site controller
							 | 
						||
| 
								 | 
							
								 */
							 | 
						||
| 
								 | 
							
								class SiteController extends Controller
							 | 
						||
| 
								 | 
							
								{
							 | 
						||
| 
								 | 
							
								    /**
							 | 
						||
| 
								 | 
							
								     * @inheritdoc
							 | 
						||
| 
								 | 
							
								     */
							 | 
						||
| 
								 | 
							
								    public function behaviors()
							 | 
						||
| 
								 | 
							
								    {
							 | 
						||
| 
								 | 
							
								        return [
							 | 
						||
| 
								 | 
							
								            'access' => [
							 | 
						||
| 
								 | 
							
								                'class' => AccessControl::className(),
							 | 
						||
| 
								 | 
							
								                'rules' => [
							 | 
						||
| 
								 | 
							
								                    [
							 | 
						||
| 
								 | 
							
								                        'actions' => ['error'],
							 | 
						||
| 
								 | 
							
								                        'allow' => true,
							 | 
						||
| 
								 | 
							
								                    ],
							 | 
						||
| 
								 | 
							
								                    [
							 | 
						||
| 
								 | 
							
								                        'actions' => ['index'],
							 | 
						||
| 
								 | 
							
								                        'allow' => true,
							 | 
						||
| 
								 | 
							
								                        'roles' => ['Dashboard'],
							 | 
						||
| 
								 | 
							
								                    ],
							 | 
						||
| 
								 | 
							
									                [    // all the action are accessible to admin
							 | 
						||
| 
								 | 
							
										                'allow' => true,
							 | 
						||
| 
								 | 
							
										                'roles' => ['admin'],
							 | 
						||
| 
								 | 
							
									                ],
							 | 
						||
| 
								 | 
							
								                ],
							 | 
						||
| 
								 | 
							
								            ],
							 | 
						||
| 
								 | 
							
								            'verbs' => [
							 | 
						||
| 
								 | 
							
								                'class' => VerbFilter::className(),
							 | 
						||
| 
								 | 
							
								                'actions' => [
							 | 
						||
| 
								 | 
							
								                    'logout' => ['post'],
							 | 
						||
| 
								 | 
							
								                ],
							 | 
						||
| 
								 | 
							
								            ],
							 | 
						||
| 
								 | 
							
								        ];
							 | 
						||
| 
								 | 
							
								    }
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								    /**
							 | 
						||
| 
								 | 
							
								     * @inheritdoc
							 | 
						||
| 
								 | 
							
								     */
							 | 
						||
| 
								 | 
							
								    public function actions()
							 | 
						||
| 
								 | 
							
								    {
							 | 
						||
| 
								 | 
							
								        return [
							 | 
						||
| 
								 | 
							
								            'error' => [
							 | 
						||
| 
								 | 
							
								                'class' => 'yii\web\ErrorAction',
							 | 
						||
| 
								 | 
							
								            ],
							 | 
						||
| 
								 | 
							
								        ];
							 | 
						||
| 
								 | 
							
								    }
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								    /**
							 | 
						||
| 
								 | 
							
								     * Displays homepage.
							 | 
						||
| 
								 | 
							
								     *
							 | 
						||
| 
								 | 
							
								     * @return string
							 | 
						||
| 
								 | 
							
								     */
							 | 
						||
| 
								 | 
							
								    public function actionIndex()
							 | 
						||
| 
								 | 
							
								    {
							 | 
						||
| 
								 | 
							
								        return $this->render('index');
							 | 
						||
| 
								 | 
							
								    }
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
									public function beforeAction($action)
							 | 
						||
| 
								 | 
							
									{
							 | 
						||
| 
								 | 
							
										if ($action->id === 'error') {
							 | 
						||
| 
								 | 
							
											$this->layout = 'error';
							 | 
						||
| 
								 | 
							
										}
							 | 
						||
| 
								 | 
							
										return parent::beforeAction($action);
							 | 
						||
| 
								 | 
							
									}
							 | 
						||
| 
								 | 
							
								}
							 |