@@ -105,8 +105,9 @@ |
||
| 105 | 105 | { |
| 106 | 106 | $config_id = 'tmp_folder'; |
| 107 | 107 | $creator = new BackupCreate($config_id); |
| 108 | - for ($i = 0; $i < 5; $i++) |
|
| 109 | - $creator->run(); |
|
| 108 | + for ($i = 0; $i < 5; $i++) { |
|
| 109 | + $creator->run(); |
|
| 110 | + } |
|
| 110 | 111 | } |
| 111 | 112 | |
| 112 | 113 | |
@@ -47,16 +47,19 @@ discard block |
||
| 47 | 47 | $this->dumperClass = $dumperClass; |
| 48 | 48 | $this->configs = Yii::$app->getModule('backup')->configs; |
| 49 | 49 | |
| 50 | - if (!is_array($this->configs) || !sizeof($this->configs)) |
|
| 51 | - throw new InvalidConfigExceptionAlias('Backup module need to be configured with `config array`'); |
|
| 50 | + if (!is_array($this->configs) || !sizeof($this->configs)) { |
|
| 51 | + throw new InvalidConfigExceptionAlias('Backup module need to be configured with `config array`'); |
|
| 52 | + } |
|
| 52 | 53 | |
| 53 | 54 | foreach ($this->configs as $config) { |
| 54 | - if (isset($config['id']) && $config['id'] == $config_id) |
|
| 55 | - $this->currentConfig = $config; |
|
| 55 | + if (isset($config['id']) && $config['id'] == $config_id) { |
|
| 56 | + $this->currentConfig = $config; |
|
| 57 | + } |
|
| 56 | 58 | } |
| 57 | 59 | |
| 58 | - if (!$this->currentConfig) |
|
| 59 | - throw new InvalidConfigExceptionAlias("Config `{$config_id}` not found."); |
|
| 60 | + if (!$this->currentConfig) { |
|
| 61 | + throw new InvalidConfigExceptionAlias("Config `{$config_id}` not found."); |
|
| 62 | + } |
|
| 60 | 63 | } |
| 61 | 64 | |
| 62 | 65 | /** |
@@ -116,17 +119,19 @@ discard block |
||
| 116 | 119 | */ |
| 117 | 120 | protected function deleteOldFiles() |
| 118 | 121 | { |
| 119 | - if (!isset($this->currentConfig['limit']) || empty($this->currentConfig['limit'])) |
|
| 120 | - return false; |
|
| 122 | + if (!isset($this->currentConfig['limit']) || empty($this->currentConfig['limit'])) { |
|
| 123 | + return false; |
|
| 124 | + } |
|
| 121 | 125 | $backups = Backup::find() |
| 122 | 126 | ->where(['config_id' => $this->currentConfig['id']]) |
| 123 | 127 | ->orderBy('date DESC') |
| 124 | 128 | ->offset($this->currentConfig['limit'] - 1) |
| 125 | 129 | ->all(); |
| 126 | 130 | |
| 127 | - if ($backups) |
|
| 128 | - foreach ($backups as $backup) |
|
| 131 | + if ($backups) { |
|
| 132 | + foreach ($backups as $backup) |
|
| 129 | 133 | $backup->delete(); |
| 134 | + } |
|
| 130 | 135 | } |
| 131 | 136 | |
| 132 | 137 | /** Generate filename |