Module.php 779 B

12345678910111213141516171819202122232425262728293031
  1. <?php
  2. /**
  3. * Created by PhpStorm.
  4. * User: NODELOG
  5. * Date: 16/8/6
  6. * Time: 下午3:41
  7. */
  8. namespace common\modules;
  9. use Yii;
  10. use yii\base\BootstrapInterface;
  11. use yii\base\Event;
  12. use yii\web\User;
  13. class Module extends \yii\base\Module
  14. {
  15. public function init()
  16. {
  17. parent::init();
  18. $class = new \ReflectionClass($this);
  19. if (Yii::$app->id == 'frontend') {
  20. $this->controllerNamespace = $class->getNamespaceName() . '\\frontend\\controllers';
  21. $this->viewPath = $this->basePath . '/frontend/views';
  22. } elseif (Yii::$app->id == 'backend') {
  23. $this->controllerNamespace = $class->getNamespaceName() . '\\backend\\controllers';
  24. $this->viewPath = $this->basePath . '/backend/views';
  25. }
  26. }
  27. }