Module.php 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. <?php
  2. namespace gii;
  3. use Yii;
  4. class Module extends \yii\gii\Module
  5. {
  6. public $allowedIPs = ['*'];
  7. public $controllerNamespace = 'gii\controllers';
  8. public function init()
  9. {
  10. parent::init();
  11. $class = new \ReflectionClass($this);
  12. if (Yii::$app->id == 'frontend') {
  13. $this->controllerNamespace = $class->getNamespaceName() . '\\frontend\\controllers';
  14. $this->viewPath = $this->basePath . '/frontend/views';
  15. } elseif (Yii::$app->id == 'backend') {
  16. $this->controllerNamespace = $class->getNamespaceName() . '\\backend\\controllers';
  17. $this->viewPath = $this->basePath . '/backend/views';
  18. }
  19. }
  20. public $generators = [
  21. 'crud' => [
  22. 'class' => 'yii\gii\generators\crud\Generator',
  23. 'templates' => [
  24. 'default' => '@gii/generators/crud/default'
  25. ]
  26. ],
  27. 'model' => [
  28. 'class' => 'gii\\generators\model\\Generator',
  29. 'useTablePrefix' => true,
  30. 'ns' => 'common\\models'
  31. ]
  32. ];
  33. }