yii\gii\Module::bootstrap PHP Method

bootstrap() public method

public bootstrap ( $app )
    public function bootstrap($app)
    {
        if ($app instanceof \yii\web\Application) {
            $app->getUrlManager()->addRules([['class' => 'yii\\web\\UrlRule', 'pattern' => $this->id, 'route' => $this->id . '/default/index'], ['class' => 'yii\\web\\UrlRule', 'pattern' => $this->id . '/<id:\\w+>', 'route' => $this->id . '/default/view'], ['class' => 'yii\\web\\UrlRule', 'pattern' => $this->id . '/<controller:[\\w\\-]+>/<action:[\\w\\-]+>', 'route' => $this->id . '/<controller>/<action>']], false);
        } elseif ($app instanceof \yii\console\Application) {
            $app->controllerMap[$this->id] = ['class' => 'yii\\gii\\console\\GenerateController', 'generators' => array_merge($this->coreGenerators(), $this->generators), 'module' => $this];
        }
    }

Usage Example

示例#1
0
 /**
  * @inheritdoc
  */
 public function bootstrap($app)
 {
     parent::bootstrap($app);
     foreach (Helper::getDbConnections() as $db) {
         if (in_array($db->getDriverName(), ['mysql', 'mysqli'])) {
             $db->schemaMap = array_merge($db->schemaMap, ['mysql' => 'yii\\gii\\plus\\db\\mysql\\Schema', 'mysqli' => 'yii\\gii\\plus\\db\\mysql\\Schema']);
         }
     }
     if ($app instanceof WebApplication) {
         $this->setViewPath(Yii::getAlias('@yii/gii/views'));
     }
 }