@@ -48,8 +48,9 @@ discard block |
||
48 | 48 | public function actionRestore(string $backup_id) |
49 | 49 | { |
50 | 50 | $model = Backup::findOne((int)$backup_id); |
51 | - if (!$model) |
|
52 | - throw new ErrorException('Backup not found.'); |
|
51 | + if (!$model) { |
|
52 | + throw new ErrorException('Backup not found.'); |
|
53 | + } |
|
53 | 54 | |
54 | 55 | Yii::createObject(BackupRestore::class, [$model])->run(); |
55 | 56 | $this->stdout('Backup restored.' . PHP_EOL, Console::FG_GREEN); |
@@ -65,13 +66,15 @@ discard block |
||
65 | 66 | { |
66 | 67 | $models = Backup::find()->orderBy('id DESC')->all(); |
67 | 68 | |
68 | - if (empty($models)) |
|
69 | - return $this->stderr('Backups not found.' . PHP_EOL, Console::FG_YELLOW); |
|
69 | + if (empty($models)) { |
|
70 | + return $this->stderr('Backups not found.' . PHP_EOL, Console::FG_YELLOW); |
|
71 | + } |
|
70 | 72 | |
71 | - foreach ($models as $model) |
|
72 | - $this->stdout("{$model->id}: " . Yii::$app->formatter->asDatetime($model->date) . "\t\t{$model->config_id}\t\t" . |
|
73 | + foreach ($models as $model) { |
|
74 | + $this->stdout("{$model->id}: " . Yii::$app->formatter->asDatetime($model->date) . "\t\t{$model->config_id}\t\t" . |
|
73 | 75 | BackupType::$list[$model->type] . |
74 | 76 | PHP_EOL, |
75 | 77 | $model->status ? Console::FG_GREEN : Console::FG_RED); |
78 | + } |
|
76 | 79 | } |
77 | 80 | } |
78 | 81 | \ No newline at end of file |
@@ -101,8 +101,9 @@ discard block |
||
101 | 101 | */ |
102 | 102 | public function actionBackup($config_id) |
103 | 103 | { |
104 | - if (!Yii::$app->getModule('backup')->checkConfig($config_id)) |
|
105 | - throw new NotFoundHttpException(Yii::t('app.f12.backup', 'Backup config is not found.')); |
|
104 | + if (!Yii::$app->getModule('backup')->checkConfig($config_id)) { |
|
105 | + throw new NotFoundHttpException(Yii::t('app.f12.backup', 'Backup config is not found.')); |
|
106 | + } |
|
106 | 107 | |
107 | 108 | Yii::createObject(BackupCreate::class, [$config_id])->run(); |
108 | 109 | |
@@ -138,8 +139,9 @@ discard block |
||
138 | 139 | protected function getBackup(int $id) |
139 | 140 | { |
140 | 141 | $this->model = Backup::findOne($id); |
141 | - if (!$this->model) |
|
142 | - throw new NotFoundHttpException(Yii::t('app.f12.backup', 'Backup is not found.')); |
|
142 | + if (!$this->model) { |
|
143 | + throw new NotFoundHttpException(Yii::t('app.f12.backup', 'Backup is not found.')); |
|
144 | + } |
|
143 | 145 | } |
144 | 146 | |
145 | 147 | /** |
@@ -150,8 +152,9 @@ discard block |
||
150 | 152 | { |
151 | 153 | $headers = Yii::$app->request->getHeaders(); |
152 | 154 | $authTokens = Yii::$app->getModule('backup')->authTokens; |
153 | - if (!empty($headers[self::HEADER_NAME]) && in_array($headers[self::HEADER_NAME], $authTokens)) |
|
154 | - return true; |
|
155 | + if (!empty($headers[self::HEADER_NAME]) && in_array($headers[self::HEADER_NAME], $authTokens)) { |
|
156 | + return true; |
|
157 | + } |
|
155 | 158 | throw new ForbiddenHttpException(); |
156 | 159 | } |
157 | 160 |