Код: Выделить всё
'on beforeAction' => function ($event) {
//$controller = $event->action->controller;
\Yii::$app->view->theme = \Yii::createObject([
'class' => 'yii\base\Theme',
'basePath' => '@app/views/def'
]);
},