Как переопределить класс View для модуля Gii в Yii2?
Есть advanced
приложение из 3х частей.
- api
- backend
- frontend
В backend
конфиге имеются такие настройки для кастомного Gii
генаратора.
'modules' => [
'gii' => [
'generators' => [
'migrik' => [
'class' => \insolita\migrik\gii\StructureGenerator::class,
'templates' => [
'custom' => '@backend/gii/templates/migrator_schema',
],
'migrationPath' => '@console/migrations/',
],
'migrikdata' => [
'class' => \insolita\migrik\gii\DataGenerator::class,
'templates' => [
'custom' => '@backend/gii/templates/migrator_data',
],
'migrationPath' => '@console/migrations/',
],
'model' => [
'class' => ModelGenerator::class,
'singularize' => True,
'enableI18N' => True,
'generateQuery' => True,
'ns' => 'core\entities',
'queryNs' => 'core\entities',
'templates' => [
'default' => '@backend/gii/templates/model/default',
'expert' => '@backend/gii/templates/model/expert'
],
'template' => 'expert'
],
'crud' => [
'class' => CRUDGenerator::class,
'baseControllerClass' => 'yii\web\Controller',
'modelClass' => 'core\entities\\',
'controllerClass' => 'backend\controllers\\',
'enableI18N' => True,
'templates' => [
'default' => '@backend/gii/templates/crud/default',
'expert' => '@backend/gii/templates/crud/expert'
],
'template' => 'expert'
]
],
]
],
Каким образом можно переопределить yii\web\View
только для модуля Gii?
Способ:
'components' => [
'view' => [
'class' => 'app\components\extended\View',
],
]
Не подходит, потому что он переопределит все представлнния, для всего backend
приложения.
Источник: Stack Overflow на русском