/** * 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]; } } }
<?php use yii\helpers\Html; use common\components\maintenance\MaintenanceAsset; MaintenanceAsset::register($this); $this->title = Yii::$app->name . ' - maintenance'; $this->beginPage(); ?> <!DOCTYPE html> <html lang="<?php echo Yii::$app->language; ?> "> <head> <meta charset="<?php echo Yii::$app->charset; ?> "> <title><?php echo Html::encode($this->title); ?> </title> <?php $this->head(); ?> </head> <body> <?php $this->beginBody();