ini_set('display_errors','On');
error_reporting(E_ALL);
namespace app\modules\car\controllers\frontend;
use app\components\Controller;
/**
* Car controller for the `car` module
*/
class CarController extends Controller
{
...
}
<?php
<?php
namespace app\components;
use Yii;
use yii\helpers\ArrayHelper;
use yii\web\Controller as YiiController; //Это базовый контроллер Yii.
/**
* Class Controller
* @package app\components
* @property \app\components\View $view
*/
class Controller extends YiiController
{
public function behaviors()
{
$allow_actions = [
'login', 'logout',
];
return [
'access' => [
'class' => \yii\filters\AccessControl::className(),
'rules' => [
[
'allow' => true,
'roles' => ['@'],
],
[
//'controllers' => ['/main/site/login'],
'actions' => $allow_actions,
'allow' => true,
'roles' => ['?'],
],
],
'denyCallback' => function($rule, $action) {
return Yii::$app->response->redirect(['/login']);
},
],
];
}
}