@@ -2,7 +2,7 @@ |
||
| 2 | 2 | |
| 3 | 3 | return [ |
| 4 | 4 | // string, required, root directory of all source files |
| 5 | - 'sourcePath' => __DIR__ . '/..', |
|
| 5 | + 'sourcePath' => __DIR__.'/..', |
|
| 6 | 6 | // array, required, list of language codes that the extracted messages |
| 7 | 7 | // should be translated to. For example, ['zh-CN', 'de']. |
| 8 | 8 | 'languages' => ['en', 'nl', 'ru', 'es', 'tr'], |
@@ -113,9 +113,9 @@ discard block |
||
| 113 | 113 | |
| 114 | 114 | // heading |
| 115 | 115 | $n = count($panels); |
| 116 | - $this->stdout("Total $n " . ($n === 1 ? 'cleanup' : 'cleanups') . " to be applied:\n", Console::FG_YELLOW); |
|
| 117 | - $this->stdout("\t" . 'DATA CLEANUP TO DATETIME' . "\n"); |
|
| 118 | - $this->stdout("\t" . '---------------------------------------------' . "\n"); |
|
| 116 | + $this->stdout("Total $n ".($n === 1 ? 'cleanup' : 'cleanups')." to be applied:\n", Console::FG_YELLOW); |
|
| 117 | + $this->stdout("\t".'DATA CLEANUP TO DATETIME'."\n"); |
|
| 118 | + $this->stdout("\t".'---------------------------------------------'."\n"); |
|
| 119 | 119 | |
| 120 | 120 | // audit panels |
| 121 | 121 | foreach ($panels as $id) { |
@@ -125,9 +125,9 @@ discard block |
||
| 125 | 125 | $dots = str_repeat('.', 24 - strlen($id)); |
| 126 | 126 | if ($age !== null) { |
| 127 | 127 | $date = date('Y-m-d 23:59:59', strtotime("-$age days")); |
| 128 | - $this->stdout("\t" . $id . ' ' . $dots . ' ' . $date . "\n"); |
|
| 128 | + $this->stdout("\t".$id.' '.$dots.' '.$date."\n"); |
|
| 129 | 129 | } else { |
| 130 | - $this->stdout("\t" . $id . ' ' . $dots . ' no maxAge, skipping' . "\n"); |
|
| 130 | + $this->stdout("\t".$id.' '.$dots.' no maxAge, skipping'."\n"); |
|
| 131 | 131 | } |
| 132 | 132 | } |
| 133 | 133 | |
@@ -135,12 +135,12 @@ discard block |
||
| 135 | 135 | if ($entry) { |
| 136 | 136 | $maxAge = $maxAge !== null ? $maxAge : $audit->maxAge; |
| 137 | 137 | $date = $maxAge !== null ? date('Y-m-d 23:59:59', strtotime("-$maxAge days")) : 'no maxAge, skipping'; |
| 138 | - $this->stdout("\t" . 'AuditEntry .............. ' . $date . "\n"); |
|
| 138 | + $this->stdout("\t".'AuditEntry .............. '.$date."\n"); |
|
| 139 | 139 | } |
| 140 | 140 | |
| 141 | 141 | // audit entry solo |
| 142 | 142 | if ($entrySolo) { |
| 143 | - $this->stdout("\t" . 'AuditEntry solo ......... ' . date('Y-m-d 23:59:59') . "\n"); |
|
| 143 | + $this->stdout("\t".'AuditEntry solo ......... '.date('Y-m-d 23:59:59')."\n"); |
|
| 144 | 144 | } |
| 145 | 145 | |
| 146 | 146 | $this->stdout("\n"); |
@@ -165,11 +165,11 @@ discard block |
||
| 165 | 165 | $count = AuditEntry::deleteAll(['<=', 'created', $date]); |
| 166 | 166 | if ($count !== false) { |
| 167 | 167 | $time = microtime(true) - $start; |
| 168 | - $this->stdout("\n*** cleaned AuditEntry (records: " . $count . ",time: " . sprintf("%.3f", $time) . "s)\n", Console::FG_GREEN); |
|
| 168 | + $this->stdout("\n*** cleaned AuditEntry (records: ".$count.",time: ".sprintf("%.3f", $time)."s)\n", Console::FG_GREEN); |
|
| 169 | 169 | return true; |
| 170 | 170 | } |
| 171 | 171 | $time = microtime(true) - $start; |
| 172 | - $this->stdout("\n*** failed to clean AuditEntry (time: " . sprintf("%.3f", $time) . "s)\n", Console::FG_RED); |
|
| 172 | + $this->stdout("\n*** failed to clean AuditEntry (time: ".sprintf("%.3f", $time)."s)\n", Console::FG_RED); |
|
| 173 | 173 | return false; |
| 174 | 174 | } |
| 175 | 175 | |
@@ -204,7 +204,7 @@ discard block |
||
| 204 | 204 | } |
| 205 | 205 | } |
| 206 | 206 | $time = microtime(true) - $start; |
| 207 | - $this->stdout("\n*** cleaned AuditEntry (records: " . $count . ",time: " . sprintf("%.3f", $time) . "s)\n", Console::FG_GREEN); |
|
| 207 | + $this->stdout("\n*** cleaned AuditEntry (records: ".$count.",time: ".sprintf("%.3f", $time)."s)\n", Console::FG_GREEN); |
|
| 208 | 208 | return true; |
| 209 | 209 | } |
| 210 | 210 | |
@@ -229,11 +229,11 @@ discard block |
||
| 229 | 229 | $count = $panel->cleanup($maxAge); |
| 230 | 230 | if ($count !== false) { |
| 231 | 231 | $time = microtime(true) - $start; |
| 232 | - $this->stdout("\n*** cleaned $id (records: " . $count . ", time: " . sprintf("%.3f", $time) . "s)\n", Console::FG_GREEN); |
|
| 232 | + $this->stdout("\n*** cleaned $id (records: ".$count.", time: ".sprintf("%.3f", $time)."s)\n", Console::FG_GREEN); |
|
| 233 | 233 | return true; |
| 234 | 234 | } |
| 235 | 235 | $time = microtime(true) - $start; |
| 236 | - $this->stdout("\n*** failed to clean $id (time: " . sprintf("%.3f", $time) . "s)\n", Console::FG_RED); |
|
| 236 | + $this->stdout("\n*** failed to clean $id (time: ".sprintf("%.3f", $time)."s)\n", Console::FG_RED); |
|
| 237 | 237 | return false; |
| 238 | 238 | } |
| 239 | 239 | |
@@ -265,13 +265,13 @@ discard block |
||
| 265 | 265 | ]; |
| 266 | 266 | $message = [ |
| 267 | 267 | 'subject' => Yii::t('audit', 'Audit Error in Audit Entry #{entry_id}', $params), |
| 268 | - 'text' => Yii::t('audit', '{message}' . "\n" . 'in {file} on line {line}.' . "\n" . '-- {url}', $params), |
|
| 268 | + 'text' => Yii::t('audit', '{message}'."\n".'in {file} on line {line}.'."\n".'-- {url}', $params), |
|
| 269 | 269 | 'html' => Yii::t('audit', '<b>{message}</b><br />in <i>{file}</i> on line <i>{line}</i>.<br/>-- {link}', $params), |
| 270 | 270 | ]; |
| 271 | 271 | |
| 272 | 272 | // send email |
| 273 | 273 | Yii::$app->mailer->compose() |
| 274 | - ->setFrom([$email => 'Audit :: ' . Yii::$app->name]) |
|
| 274 | + ->setFrom([$email => 'Audit :: '.Yii::$app->name]) |
|
| 275 | 275 | ->setTo($email) |
| 276 | 276 | ->setSubject($message['subject']) |
| 277 | 277 | ->setTextBody($message['text']) |
@@ -180,7 +180,7 @@ discard block |
||
| 180 | 180 | */ |
| 181 | 181 | protected function cleanAttributesIgnored($attributes) |
| 182 | 182 | { |
| 183 | - if(is_array($this->timestamp_fields) && count($this->timestamp_fields) > 0) { |
|
| 183 | + if (is_array($this->timestamp_fields) && count($this->timestamp_fields) > 0) { |
|
| 184 | 184 | $this->ignored = array_merge($this->ignored, $this->timestamp_fields); |
| 185 | 185 | } |
| 186 | 186 | |
@@ -202,12 +202,12 @@ discard block |
||
| 202 | 202 | */ |
| 203 | 203 | protected function cleanAttributesOverride($attributes) |
| 204 | 204 | { |
| 205 | - if (sizeof($this->override) > 0 && sizeof($attributes) >0) { |
|
| 205 | + if (sizeof($this->override) > 0 && sizeof($attributes) > 0) { |
|
| 206 | 206 | foreach ($this->override as $field => $queryParams) { |
| 207 | 207 | $newOverrideValues = $this->getNewOverrideValues($attributes[$field], $queryParams); |
| 208 | 208 | $saveField = \yii\helpers\ArrayHelper::getValue($queryParams, 'saveField', $field); |
| 209 | 209 | |
| 210 | - if (count($newOverrideValues) >1) { |
|
| 210 | + if (count($newOverrideValues) > 1) { |
|
| 211 | 211 | $attributes[$saveField] = implode(', ', |
| 212 | 212 | \yii\helpers\ArrayHelper::map($newOverrideValues, $queryParams['returnField'], $queryParams['returnField']) |
| 213 | 213 | ); |
@@ -249,12 +249,12 @@ discard block |
||
| 249 | 249 | $oldAttributes = $this->cleanAttributes($this->getOldAttributes()); |
| 250 | 250 | |
| 251 | 251 | // ensure to handle serialized attributes properly |
| 252 | - foreach($newAttributes as $key => $value) |
|
| 253 | - if(is_array($newAttributes[$key])) |
|
| 252 | + foreach ($newAttributes as $key => $value) |
|
| 253 | + if (is_array($newAttributes[$key])) |
|
| 254 | 254 | $newAttributes[$key] = Json::encode($newAttributes[$key]); |
| 255 | 255 | |
| 256 | - foreach($oldAttributes as $key => $value) |
|
| 257 | - if(is_array($oldAttributes[$key])) |
|
| 256 | + foreach ($oldAttributes as $key => $value) |
|
| 257 | + if (is_array($oldAttributes[$key])) |
|
| 258 | 258 | $oldAttributes[$key] = Json::encode($oldAttributes[$key]); |
| 259 | 259 | |
| 260 | 260 | // If no difference then get out of here |