Example #1
0
 public function __construct($module = null)
 {
     if ($module === null) {
         $module = \Application::getModule();
     }
     $modulePath = \Application::getFolders()->get('modules') . '/' . str_replace('\\', '/', $module) . '/View/';
     if (!file_exists($modulePath)) {
         throw new FatalException('Path not found: ' . $modulePath);
     }
     $this->modulePath = $modulePath;
 }
Example #2
0
 /**
  * Bootstrap method to be called during application bootstrap stage.
  *
  * @param Application $app the application currently running
  */
 public function bootstrap($app)
 {
     /** @var Module $module */
     if ($app->hasModule('user') && ($module = $app->getModule('user')) instanceof Module) {
         if (!isset($app->get('i18n')->translations['user*'])) {
             $app->get('i18n')->translations['user*'] = ['class' => PhpMessageSource::className(), 'basePath' => __DIR__ . '/messages'];
         }
         if ($app instanceof ConsoleApplication) {
             $module->controllerNamespace = 'johnitvn\\userplus\\commands';
         } else {
             $module->controllerNamespace = 'johnitvn\\userplus\\controllers';
         }
     }
 }
Example #3
0
 /**
  * Bootstrap method to be called during application bootstrap stage.
  *
  * @param Application $app the application currently running
  */
 public function bootstrap($app)
 {
     /**
      * Check when this application contain f2ngin module config
      */
     if ($app->hasModule('f2ngin')) {
         $module = $app->getModule('f2ngin');
         // Set alias for @f2ngin for easy use path
         Yii::setAlias("@f2ngin", "@vendor/johnitvn/yii2-f2ngin/src");
         // Config internationalisation
         if (!isset(Yii::$app->get('i18n')->translations['user*'])) {
             Yii::$app->get('i18n')->translations['user*'] = ['class' => PhpMessageSource::className(), 'basePath' => __DIR__ . '/messages'];
         }
         // config for web application
         if ($app instanceof \yii\web\Application) {
             $this->bootstrapWebApp($app, $module);
         }
     }
     // config for console application
     if ($app instanceof \yii\console\Application) {
         $this->bootstrapConsoleApp($app);
     }
 }