@@ -10,10 +10,10 @@ |
||
| 10 | 10 | |
| 11 | 11 | namespace bedezign\yii2\audit; |
| 12 | 12 | |
| 13 | +use Yii; |
|
| 13 | 14 | use bedezign\yii2\audit\components\panels\Panel; |
| 14 | 15 | use bedezign\yii2\audit\models\AuditEntry; |
| 15 | 16 | use bedezign\yii2\audit\models\AuditError; |
| 16 | -use Yii; |
|
| 17 | 17 | use yii\base\ActionEvent; |
| 18 | 18 | use yii\base\Application; |
| 19 | 19 | use yii\base\InvalidConfigException; |
@@ -239,8 +239,9 @@ discard block |
||
| 239 | 239 | */ |
| 240 | 240 | public function registerFunction($name, $callback) |
| 241 | 241 | { |
| 242 | - if (isset($this->_panelFunctions[$name])) |
|
| 243 | - throw new InvalidParamException("The '$name'-function has already been defined."); |
|
| 242 | + if (isset($this->_panelFunctions[$name])) { |
|
| 243 | + throw new InvalidParamException("The '$name'-function has already been defined."); |
|
| 244 | + } |
|
| 244 | 245 | |
| 245 | 246 | $this->_panelFunctions[$name] = $callback; |
| 246 | 247 | } |
@@ -260,8 +261,9 @@ discard block |
||
| 260 | 261 | */ |
| 261 | 262 | public function __call($name, $params) |
| 262 | 263 | { |
| 263 | - if (!isset($this->_panelFunctions[$name])) |
|
| 264 | - throw new \yii\base\InvalidCallException("Unknown panel function '$name'"); |
|
| 264 | + if (!isset($this->_panelFunctions[$name])) { |
|
| 265 | + throw new \yii\base\InvalidCallException("Unknown panel function '$name'"); |
|
| 266 | + } |
|
| 265 | 267 | |
| 266 | 268 | return call_user_func_array($this->_panelFunctions[$name], $params); |
| 267 | 269 | } |
@@ -333,13 +335,15 @@ discard block |
||
| 333 | 335 | public function getPanel($identifier) |
| 334 | 336 | { |
| 335 | 337 | $config = null; |
| 336 | - if (isset($this->panels[$identifier])) |
|
| 337 | - $config = $this->panels[$identifier]; |
|
| 338 | - elseif (isset($this->_corePanels[$identifier])) |
|
| 339 | - $config = $this->_corePanels[$identifier]; |
|
| 338 | + if (isset($this->panels[$identifier])) { |
|
| 339 | + $config = $this->panels[$identifier]; |
|
| 340 | + } elseif (isset($this->_corePanels[$identifier])) { |
|
| 341 | + $config = $this->_corePanels[$identifier]; |
|
| 342 | + } |
|
| 340 | 343 | |
| 341 | - if (!$config) |
|
| 342 | - throw new InvalidConfigException("'$identifier' is not a valid panel identifier"); |
|
| 344 | + if (!$config) { |
|
| 345 | + throw new InvalidConfigException("'$identifier' is not a valid panel identifier"); |
|
| 346 | + } |
|
| 343 | 347 | |
| 344 | 348 | if (is_array($config)) { |
| 345 | 349 | $config['module'] = $this; |
@@ -360,11 +364,11 @@ discard block |
||
| 360 | 364 | foreach ($this->panels as $key => $value) { |
| 361 | 365 | if (is_numeric($key)) { |
| 362 | 366 | // The $value contains the identifier of a core panel |
| 363 | - if (!isset($this->_corePanels[$value])) |
|
| 364 | - throw new InvalidConfigException("'$value' is not a valid panel identifier"); |
|
| 367 | + if (!isset($this->_corePanels[$value])) { |
|
| 368 | + throw new InvalidConfigException("'$value' is not a valid panel identifier"); |
|
| 369 | + } |
|
| 365 | 370 | $panels[$value] = $this->_corePanels[$value]; |
| 366 | - } |
|
| 367 | - else { |
|
| 371 | + } else { |
|
| 368 | 372 | // The key contains the identifier and the value is either a class name or a full array |
| 369 | 373 | $panels[$key] = is_string($value) ? ['class' => $value] : $value; |
| 370 | 374 | } |
@@ -374,10 +378,11 @@ discard block |
||
| 374 | 378 | // We now need one more iteration to add core classes to the panels added via the merge, if needed |
| 375 | 379 | array_walk($this->panels, function(&$value, $key) { |
| 376 | 380 | if (!isset($value['class'])) { |
| 377 | - if (isset($this->_corePanels[$key])) |
|
| 378 | - $value = ArrayHelper::merge($value, $this->_corePanels[$key]); |
|
| 379 | - else |
|
| 380 | - throw new InvalidConfigException("Invalid configuration for '$key'. No 'class' specified."); |
|
| 381 | + if (isset($this->_corePanels[$key])) { |
|
| 382 | + $value = ArrayHelper::merge($value, $this->_corePanels[$key]); |
|
| 383 | + } else { |
|
| 384 | + throw new InvalidConfigException("Invalid configuration for '$key'. No 'class' specified."); |
|
| 385 | + } |
|
| 381 | 386 | } |
| 382 | 387 | }); |
| 383 | 388 | } |
@@ -389,18 +394,21 @@ discard block |
||
| 389 | 394 | { |
| 390 | 395 | foreach (Yii::$app->modules as $name => $module) { |
| 391 | 396 | $class = null; |
| 392 | - if (is_string($module)) |
|
| 393 | - $class = $module; |
|
| 394 | - elseif (is_array($module)) { |
|
| 395 | - if (isset($module['class'])) |
|
| 396 | - $class = $module['class']; |
|
| 397 | - } else |
|
| 398 | - /** @var Module $module */ |
|
| 397 | + if (is_string($module)) { |
|
| 398 | + $class = $module; |
|
| 399 | + } elseif (is_array($module)) { |
|
| 400 | + if (isset($module['class'])) { |
|
| 401 | + $class = $module['class']; |
|
| 402 | + } |
|
| 403 | + } else { |
|
| 404 | + /** @var Module $module */ |
|
| 399 | 405 | $class = $module::className(); |
| 406 | + } |
|
| 400 | 407 | |
| 401 | 408 | $parts = explode('\\', $class); |
| 402 | - if ($class && strtolower(end($parts)) == 'audit') |
|
| 403 | - return $name; |
|
| 409 | + if ($class && strtolower(end($parts)) == 'audit') { |
|
| 410 | + return $name; |
|
| 411 | + } |
|
| 404 | 412 | } |
| 405 | 413 | return null; |
| 406 | 414 | } |
@@ -436,12 +444,14 @@ discard block |
||
| 436 | 444 | $len = strlen($compare); |
| 437 | 445 | if ($compare[$len - 1] == '*') { |
| 438 | 446 | $compare = rtrim($compare, '*'); |
| 439 | - if (substr($route, 0, $len - 1) === $compare) |
|
| 440 | - return true; |
|
| 447 | + if (substr($route, 0, $len - 1) === $compare) { |
|
| 448 | + return true; |
|
| 449 | + } |
|
| 441 | 450 | } |
| 442 | 451 | |
| 443 | - if ($route === $compare) |
|
| 444 | - return true; |
|
| 452 | + if ($route === $compare) { |
|
| 453 | + return true; |
|
| 454 | + } |
|
| 445 | 455 | } |
| 446 | 456 | return false; |
| 447 | 457 | } |
@@ -8,8 +8,8 @@ |
||
| 8 | 8 | |
| 9 | 9 | use Yii; |
| 10 | 10 | use bedezign\yii2\audit\components\panels\DataStoragePanel; |
| 11 | -use yii\grid\GridViewAsset; |
|
| 12 | 11 | use yii\data\ArrayDataProvider; |
| 12 | +use yii\grid\GridViewAsset; |
|
| 13 | 13 | |
| 14 | 14 | /** |
| 15 | 15 | * Class CurlPanel |
@@ -96,19 +96,22 @@ discard block |
||
| 96 | 96 | curl_setopt($handle, CURLOPT_URL, $url); |
| 97 | 97 | } |
| 98 | 98 | |
| 99 | - if ($postData) |
|
| 100 | - $this->data[$id]['post'] = $postData; |
|
| 99 | + if ($postData) { |
|
| 100 | + $this->data[$id]['post'] = $postData; |
|
| 101 | + } |
|
| 101 | 102 | |
| 102 | - if ($this->headers) |
|
| 103 | - curl_setopt($handle, CURLOPT_HEADERFUNCTION, [$this, 'captureHeader']); |
|
| 103 | + if ($this->headers) { |
|
| 104 | + curl_setopt($handle, CURLOPT_HEADERFUNCTION, [$this, 'captureHeader']); |
|
| 105 | + } |
|
| 104 | 106 | |
| 105 | 107 | if ($this->log) { |
| 106 | 108 | curl_setopt($handle, CURLOPT_VERBOSE, true); |
| 107 | 109 | curl_setopt($handle, CURLOPT_STDERR, $this->_logHandles[$id] = fopen('php://temp', 'rw+')); |
| 108 | 110 | } |
| 109 | 111 | |
| 110 | - if ($this->content) |
|
| 111 | - curl_setopt($handle, CURLOPT_RETURNTRANSFER, 1); |
|
| 112 | + if ($this->content) { |
|
| 113 | + curl_setopt($handle, CURLOPT_RETURNTRANSFER, 1); |
|
| 114 | + } |
|
| 112 | 115 | |
| 113 | 116 | return true; |
| 114 | 117 | } |
@@ -136,8 +139,9 @@ discard block |
||
| 136 | 139 | unset($this->_logHandles[$id]); |
| 137 | 140 | } |
| 138 | 141 | |
| 139 | - if ($this->content) |
|
| 140 | - $this->data[$id]['content']= curl_multi_getcontent($handle); |
|
| 142 | + if ($this->content) { |
|
| 143 | + $this->data[$id]['content']= curl_multi_getcontent($handle); |
|
| 144 | + } |
|
| 141 | 145 | |
| 142 | 146 | // Cleanup empty things |
| 143 | 147 | $this->data[$id] = array_filter($this->data[$id]); |
@@ -192,8 +196,9 @@ discard block |
||
| 192 | 196 | public function captureHeader($handle, $header) |
| 193 | 197 | { |
| 194 | 198 | $id = $this->id($handle); |
| 195 | - if (!isset($this->data[$id]['headers'])) |
|
| 196 | - $this->data[$id]['headers'] = []; |
|
| 199 | + if (!isset($this->data[$id]['headers'])) { |
|
| 200 | + $this->data[$id]['headers'] = []; |
|
| 201 | + } |
|
| 197 | 202 | |
| 198 | 203 | $this->data[$id]['headers'][] = $header; |
| 199 | 204 | return strlen($header); |
@@ -205,8 +210,9 @@ discard block |
||
| 205 | 210 | */ |
| 206 | 211 | protected function id($resource) |
| 207 | 212 | { |
| 208 | - if (!is_resource($resource)) |
|
| 209 | - return false; |
|
| 213 | + if (!is_resource($resource)) { |
|
| 214 | + return false; |
|
| 215 | + } |
|
| 210 | 216 | |
| 211 | 217 | $parts = explode('#', (string)$resource); |
| 212 | 218 | return array_pop($parts); |
@@ -2,8 +2,8 @@ |
||
| 2 | 2 | |
| 3 | 3 | namespace bedezign\yii2\audit\panels; |
| 4 | 4 | |
| 5 | -use bedezign\yii2\audit\components\panels\DataStoragePanelTrait; |
|
| 6 | 5 | use Yii; |
| 6 | +use bedezign\yii2\audit\components\panels\DataStoragePanelTrait; |
|
| 7 | 7 | use yii\debug\models\search\Db; |
| 8 | 8 | use yii\grid\GridViewAsset; |
| 9 | 9 | |
@@ -2,12 +2,12 @@ |
||
| 2 | 2 | |
| 3 | 3 | namespace bedezign\yii2\audit\panels; |
| 4 | 4 | |
| 5 | +use Exception; |
|
| 6 | +use Yii; |
|
| 5 | 7 | use bedezign\yii2\audit\components\Helper; |
| 6 | 8 | use bedezign\yii2\audit\components\panels\Panel; |
| 7 | 9 | use bedezign\yii2\audit\models\AuditError; |
| 8 | 10 | use bedezign\yii2\audit\models\AuditErrorSearch; |
| 9 | -use Exception; |
|
| 10 | -use Yii; |
|
| 11 | 11 | use yii\grid\GridViewAsset; |
| 12 | 12 | |
| 13 | 13 | /** |
@@ -47,12 +47,14 @@ discard block |
||
| 47 | 47 | { |
| 48 | 48 | // Only log each exception once |
| 49 | 49 | $exceptionId = spl_object_hash($exception); |
| 50 | - if (in_array($exceptionId, $this->_exceptions)) |
|
| 51 | - return true; |
|
| 50 | + if (in_array($exceptionId, $this->_exceptions)) { |
|
| 51 | + return true; |
|
| 52 | + } |
|
| 52 | 53 | |
| 53 | 54 | // If this is a follow up exception, make sure to log the base exception first |
| 54 | - if ($exception->getPrevious()) |
|
| 55 | - $this->log($entry_id, $exception->getPrevious()); |
|
| 55 | + if ($exception->getPrevious()) { |
|
| 56 | + $this->log($entry_id, $exception->getPrevious()); |
|
| 57 | + } |
|
| 56 | 58 | |
| 57 | 59 | $error = new AuditError(); |
| 58 | 60 | $error->entry_id = $entry_id; |
@@ -165,8 +167,9 @@ discard block |
||
| 165 | 167 | public function cleanup($maxAge = null) |
| 166 | 168 | { |
| 167 | 169 | $maxAge = $maxAge !== null ? $maxAge : $this->maxAge; |
| 168 | - if ($maxAge === null) |
|
| 169 | - return false; |
|
| 170 | + if ($maxAge === null) { |
|
| 171 | + return false; |
|
| 172 | + } |
|
| 170 | 173 | return AuditError::deleteAll([ |
| 171 | 174 | '<=', 'created', date('Y-m-d 23:59:59', strtotime("-$maxAge days")) |
| 172 | 175 | ]); |
@@ -2,10 +2,10 @@ |
||
| 2 | 2 | |
| 3 | 3 | namespace bedezign\yii2\audit\panels; |
| 4 | 4 | |
| 5 | +use Yii; |
|
| 5 | 6 | use bedezign\yii2\audit\components\panels\Panel; |
| 6 | 7 | use bedezign\yii2\audit\models\AuditJavascript; |
| 7 | 8 | use bedezign\yii2\audit\models\AuditJavascriptSearch; |
| 8 | -use Yii; |
|
| 9 | 9 | use yii\grid\GridViewAsset; |
| 10 | 10 | |
| 11 | 11 | /** |
@@ -87,8 +87,9 @@ |
||
| 87 | 87 | public function cleanup($maxAge = null) |
| 88 | 88 | { |
| 89 | 89 | $maxAge = $maxAge !== null ? $maxAge : $this->maxAge; |
| 90 | - if ($maxAge === null) |
|
| 91 | - return false; |
|
| 90 | + if ($maxAge === null) { |
|
| 91 | + return false; |
|
| 92 | + } |
|
| 92 | 93 | return AuditJavascript::deleteAll([ |
| 93 | 94 | '<=', 'created', date('Y-m-d 23:59:59', strtotime("-$maxAge days")) |
| 94 | 95 | ]); |
@@ -2,8 +2,8 @@ |
||
| 2 | 2 | |
| 3 | 3 | namespace bedezign\yii2\audit\panels; |
| 4 | 4 | |
| 5 | -use bedezign\yii2\audit\components\panels\DataStoragePanelTrait; |
|
| 6 | 5 | use Yii; |
| 6 | +use bedezign\yii2\audit\components\panels\DataStoragePanelTrait; |
|
| 7 | 7 | use yii\debug\models\search\Log; |
| 8 | 8 | use yii\grid\GridViewAsset; |
| 9 | 9 | |
@@ -2,14 +2,14 @@ |
||
| 2 | 2 | |
| 3 | 3 | namespace bedezign\yii2\audit\panels; |
| 4 | 4 | |
| 5 | -use bedezign\yii2\audit\Audit; |
|
| 6 | -use bedezign\yii2\audit\components\panels\Panel; |
|
| 7 | -use bedezign\yii2\audit\models\AuditMail; |
|
| 8 | -use bedezign\yii2\audit\models\AuditMailSearch; |
|
| 9 | 5 | use Swift_Message; |
| 10 | 6 | use Swift_Mime_Attachment; |
| 11 | 7 | use Swift_Mime_MimePart; |
| 12 | 8 | use Yii; |
| 9 | +use bedezign\yii2\audit\Audit; |
|
| 10 | +use bedezign\yii2\audit\components\panels\Panel; |
|
| 11 | +use bedezign\yii2\audit\models\AuditMail; |
|
| 12 | +use bedezign\yii2\audit\models\AuditMailSearch; |
|
| 13 | 13 | use yii\base\Event; |
| 14 | 14 | use yii\grid\GridViewAsset; |
| 15 | 15 | use yii\mail\BaseMailer; |
@@ -167,8 +167,9 @@ |
||
| 167 | 167 | public function cleanup($maxAge = null) |
| 168 | 168 | { |
| 169 | 169 | $maxAge = $maxAge !== null ? $maxAge : $this->maxAge; |
| 170 | - if ($maxAge === null) |
|
| 171 | - return false; |
|
| 170 | + if ($maxAge === null) { |
|
| 171 | + return false; |
|
| 172 | + } |
|
| 172 | 173 | return AuditMail::deleteAll([ |
| 173 | 174 | '<=', 'created', date('Y-m-d 23:59:59', strtotime("-$maxAge days")) |
| 174 | 175 | ]); |
@@ -2,8 +2,8 @@ |
||
| 2 | 2 | |
| 3 | 3 | namespace bedezign\yii2\audit\panels; |
| 4 | 4 | |
| 5 | -use bedezign\yii2\audit\components\panels\DataStoragePanelTrait; |
|
| 6 | 5 | use Yii; |
| 6 | +use bedezign\yii2\audit\components\panels\DataStoragePanelTrait; |
|
| 7 | 7 | use yii\debug\models\search\Profile; |
| 8 | 8 | use yii\grid\GridViewAsset; |
| 9 | 9 | |
@@ -2,7 +2,6 @@ |
||
| 2 | 2 | namespace bedezign\yii2\audit\panels; |
| 3 | 3 | |
| 4 | 4 | use Yii; |
| 5 | -use bedezign\yii2\audit\models\AuditError; |
|
| 6 | 5 | use bedezign\yii2\audit\components\panels\DataStoragePanel; |
| 7 | 6 | use yii\data\ArrayDataProvider; |
| 8 | 7 | |
@@ -35,8 +35,9 @@ |
||
| 35 | 35 | { |
| 36 | 36 | $this->module->registerPanel($this); |
| 37 | 37 | |
| 38 | - if (!is_array($this->data)) |
|
| 39 | - $this->data = []; |
|
| 38 | + if (!is_array($this->data)) { |
|
| 39 | + $this->data = []; |
|
| 40 | + } |
|
| 40 | 41 | |
| 41 | 42 | if (isset($data['error'])) { |
| 42 | 43 | $error = $this->module->exception($data['error']); |