@@ -291,8 +291,9 @@ discard block |
||
291 | 291 | */ |
292 | 292 | public function registerFunction($name, $callback) |
293 | 293 | { |
294 | - if (isset($this->_panelFunctions[$name])) |
|
295 | - throw new InvalidParamException("The '$name'-function has already been defined."); |
|
294 | + if (isset($this->_panelFunctions[$name])) { |
|
295 | + throw new InvalidParamException("The '$name'-function has already been defined."); |
|
296 | + } |
|
296 | 297 | |
297 | 298 | $this->_panelFunctions[$name] = $callback; |
298 | 299 | } |
@@ -320,8 +321,9 @@ discard block |
||
320 | 321 | */ |
321 | 322 | public function __call($name, $params) |
322 | 323 | { |
323 | - if (!isset($this->_panelFunctions[$name])) |
|
324 | - throw new \yii\base\InvalidCallException("Unknown panel function '$name'"); |
|
324 | + if (!isset($this->_panelFunctions[$name])) { |
|
325 | + throw new \yii\base\InvalidCallException("Unknown panel function '$name'"); |
|
326 | + } |
|
325 | 327 | |
326 | 328 | return call_user_func_array($this->_panelFunctions[$name], $params); |
327 | 329 | } |
@@ -459,13 +461,15 @@ discard block |
||
459 | 461 | public function getPanel($identifier) |
460 | 462 | { |
461 | 463 | $config = null; |
462 | - if (isset($this->panels[$identifier])) |
|
463 | - $config = $this->panels[$identifier]; |
|
464 | - elseif (isset($this->_corePanels[$identifier])) |
|
465 | - $config = $this->_corePanels[$identifier]; |
|
464 | + if (isset($this->panels[$identifier])) { |
|
465 | + $config = $this->panels[$identifier]; |
|
466 | + } elseif (isset($this->_corePanels[$identifier])) { |
|
467 | + $config = $this->_corePanels[$identifier]; |
|
468 | + } |
|
466 | 469 | |
467 | - if (!$config) |
|
468 | - throw new InvalidConfigException("'$identifier' is not a valid panel identifier"); |
|
470 | + if (!$config) { |
|
471 | + throw new InvalidConfigException("'$identifier' is not a valid panel identifier"); |
|
472 | + } |
|
469 | 473 | |
470 | 474 | if (is_array($config)) { |
471 | 475 | $config['module'] = $this; |
@@ -486,11 +490,11 @@ discard block |
||
486 | 490 | foreach ($this->panels as $key => $value) { |
487 | 491 | if (is_numeric($key)) { |
488 | 492 | // The $value contains the identifier of a core panel |
489 | - if (!isset($this->_corePanels[$value])) |
|
490 | - throw new InvalidConfigException("'$value' is not a valid panel identifier"); |
|
493 | + if (!isset($this->_corePanels[$value])) { |
|
494 | + throw new InvalidConfigException("'$value' is not a valid panel identifier"); |
|
495 | + } |
|
491 | 496 | $panels[$value] = $this->_corePanels[$value]; |
492 | - } |
|
493 | - else { |
|
497 | + } else { |
|
494 | 498 | // The key contains the identifier and the value is either a class name or a full array |
495 | 499 | $panels[$key] = is_string($value) ? ['class' => $value] : $value; |
496 | 500 | } |
@@ -500,10 +504,11 @@ discard block |
||
500 | 504 | // We now need one more iteration to add core classes to the panels added via the merge, if needed |
501 | 505 | array_walk($this->panels, function(&$value, $key) { |
502 | 506 | if (!isset($value['class'])) { |
503 | - if (isset($this->_corePanels[$key])) |
|
504 | - $value = ArrayHelper::merge($value, $this->_corePanels[$key]); |
|
505 | - else |
|
506 | - throw new InvalidConfigException("Invalid configuration for '$key'. No 'class' specified."); |
|
507 | + if (isset($this->_corePanels[$key])) { |
|
508 | + $value = ArrayHelper::merge($value, $this->_corePanels[$key]); |
|
509 | + } else { |
|
510 | + throw new InvalidConfigException("Invalid configuration for '$key'. No 'class' specified."); |
|
511 | + } |
|
507 | 512 | } |
508 | 513 | }); |
509 | 514 | } |
@@ -515,18 +520,21 @@ discard block |
||
515 | 520 | { |
516 | 521 | foreach (Yii::$app->modules as $name => $module) { |
517 | 522 | $class = null; |
518 | - if (is_string($module)) |
|
519 | - $class = $module; |
|
520 | - elseif (is_array($module)) { |
|
521 | - if (isset($module['class'])) |
|
522 | - $class = $module['class']; |
|
523 | - } else |
|
524 | - /** @var Module $module */ |
|
523 | + if (is_string($module)) { |
|
524 | + $class = $module; |
|
525 | + } elseif (is_array($module)) { |
|
526 | + if (isset($module['class'])) { |
|
527 | + $class = $module['class']; |
|
528 | + } |
|
529 | + } else { |
|
530 | + /** @var Module $module */ |
|
525 | 531 | $class = $module::className(); |
532 | + } |
|
526 | 533 | |
527 | 534 | $parts = explode('\\', $class); |
528 | - if ($class && strtolower(end($parts)) == 'audit') |
|
529 | - return $name; |
|
535 | + if ($class && strtolower(end($parts)) == 'audit') { |
|
536 | + return $name; |
|
537 | + } |
|
530 | 538 | } |
531 | 539 | return null; |
532 | 540 | } |
@@ -562,18 +570,21 @@ discard block |
||
562 | 570 | $len = strlen($compare); |
563 | 571 | if ($compare[$len - 1] == '*') { |
564 | 572 | $compare = rtrim($compare, '*'); |
565 | - if (substr($route, 0, $len - 1) === $compare) |
|
566 | - return true; |
|
573 | + if (substr($route, 0, $len - 1) === $compare) { |
|
574 | + return true; |
|
575 | + } |
|
567 | 576 | } |
568 | 577 | |
569 | 578 | if ($compare[0] == '*') { |
570 | 579 | $compare = ltrim($compare, '*'); |
571 | - if (substr($route, - ($len - 1)) === $compare) |
|
572 | - return true; |
|
580 | + if (substr($route, - ($len - 1)) === $compare) { |
|
581 | + return true; |
|
582 | + } |
|
573 | 583 | } |
574 | 584 | |
575 | - if ($route === $compare) |
|
576 | - return true; |
|
585 | + if ($route === $compare) { |
|
586 | + return true; |
|
587 | + } |
|
577 | 588 | } |
578 | 589 | return false; |
579 | 590 | } |