Esempio n. 1
0
 /**
  * Bootstrap method to be called during application bootstrap stage.
  * @param \yii\web\Application $app the application currently running
  */
 public function bootstrap($app)
 {
     if ($this->enabled instanceof \Closure) {
         $enabled = call_user_func($this->enabled, $app);
     } else {
         $enabled = $this->enabled;
     }
     if ($enabled) {
         $this->maintenanceText = $this->maintenanceText ?: \Yii::t('common', 'Down to maintenance.');
         if ($this->catchAllRoute === null) {
             $app->controllerMap['maintenance'] = ['class' => 'common\\components\\maintenance\\controllers\\MaintenanceController', 'retryAfter' => $this->retryAfter, 'maintenanceLayout' => $this->maintenanceLayout, 'maintenanceView' => $this->maintenanceView, 'maintenanceText' => $this->maintenanceText];
             $app->catchAll = ['maintenance/index'];
             \Yii::$app->view->registerAssetBundle(MaintenanceAsset::className());
         } else {
             $app->catchAll = [$this->catchAllRoute, 'retryAfter' => $this->retryAfter, 'maintenanceText' => $this->maintenanceText];
         }
     }
 }