示例#1
2
 /**
  * Bootstraps the module for the web application.
  *
  * @param \yii\web\Application $app application instance.
  */
 protected function bootstrapWebApplication($app)
 {
     /** @var Module $module */
     $module = $app->getModule(Module::MODULE_ID);
     // prepend the URL rules to the URL manager
     $app->getUrlManager()->addRules([new GroupUrlRule($module->urlConfig)], false);
     // Configure the web user component
     $app->set('user', ArrayHelper::merge(['class' => $module->getClassName(Module::CLASS_WEB_USER), 'identityClass' => $module->getClassName(Module::CLASS_ACCOUNT), 'loginUrl' => $module->createRoute(Module::URL_ROUTE_LOGIN), 'enableAutoLogin' => true], $module->userConfig));
     // configure client authentication if necessary
     if ($module->enableClientAuth && !$app->has('authClientCollection')) {
         $app->set('authClientCollection', ArrayHelper::merge(['class' => Collection::className(), 'clients' => ['google' => ['class' => GoogleOpenId::className()]]], $module->clientAuthConfig));
     }
 }
示例#2
0
 /**
  * @param $app
  */
 protected function persistDb()
 {
     // always use the same DB connection
     if (static::$db) {
         $this->app->set('db', static::$db);
     } elseif ($this->app->has('db')) {
         static::$db = $this->app->get('db');
     }
 }