@@ -44,16 +44,19 @@ |
||
44 | 44 | { |
45 | 45 | $this->_configs = Yii::$app->getModule('backup')->configs; |
46 | 46 | |
47 | - if (!is_array($this->_configs) || !sizeof($this->_configs)) |
|
48 | - throw new InvalidConfigException('Backup module need to be configured with `config array`'); |
|
47 | + if (!is_array($this->_configs) || !sizeof($this->_configs)) { |
|
48 | + throw new InvalidConfigException('Backup module need to be configured with `config array`'); |
|
49 | + } |
|
49 | 50 | |
50 | 51 | foreach ($this->_configs as $config) { |
51 | - if (isset($config['id']) && $config['id'] == $model->config_id) |
|
52 | - $this->_currentConfig = $config; |
|
52 | + if (isset($config['id']) && $config['id'] == $model->config_id) { |
|
53 | + $this->_currentConfig = $config; |
|
54 | + } |
|
53 | 55 | } |
54 | 56 | |
55 | - if (!$this->_currentConfig) |
|
56 | - throw new ErrorException("Config `{$model->config_id}` not found."); |
|
57 | + if (!$this->_currentConfig) { |
|
58 | + throw new ErrorException("Config `{$model->config_id}` not found."); |
|
59 | + } |
|
57 | 60 | |
58 | 61 | $this->_model = $model; |
59 | 62 | $this->backupFilePath = Yii::getAlias(Yii::$app->getModule('backup')->backupFolder . DIRECTORY_SEPARATOR . $this->_model->filename); |
@@ -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 |
@@ -68,7 +68,7 @@ |
||
68 | 68 | $this->assertTrue(is_object($backup)); |
69 | 69 | $this->assertEquals(BackupType::FILES, $backup->type); |
70 | 70 | $this->assertFileExists($backup->getFullPath()); |
71 | - // @unlink($backup->getFullPath()); |
|
71 | + // @unlink($backup->getFullPath()); |
|
72 | 72 | } |
73 | 73 | |
74 | 74 | public function testSaveAllOldBackups() |
@@ -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 | /** |
@@ -91,17 +94,19 @@ discard block |
||
91 | 94 | */ |
92 | 95 | protected function deleteOldFiles() |
93 | 96 | { |
94 | - if (!isset($this->currentConfig['limit']) || empty($this->currentConfig['limit'])) |
|
95 | - return false; |
|
97 | + if (!isset($this->currentConfig['limit']) || empty($this->currentConfig['limit'])) { |
|
98 | + return false; |
|
99 | + } |
|
96 | 100 | $backups = Backup::find() |
97 | 101 | ->where(['config_id' => $this->currentConfig['id']]) |
98 | 102 | ->orderBy('date DESC') |
99 | 103 | ->offset($this->currentConfig['limit'] - 1) |
100 | 104 | ->all(); |
101 | 105 | |
102 | - if ($backups) |
|
103 | - foreach ($backups as $backup) |
|
106 | + if ($backups) { |
|
107 | + foreach ($backups as $backup) |
|
104 | 108 | $backup->delete(); |
109 | + } |
|
105 | 110 | } |
106 | 111 | |
107 | 112 | /** |