diff --git a/library/Icinga/Web/Widget/Dashboard/Pane.php b/library/Icinga/Web/Widget/Dashboard/Pane.php index 5f973885f..d4679042d 100644 --- a/library/Icinga/Web/Widget/Dashboard/Pane.php +++ b/library/Icinga/Web/Widget/Dashboard/Pane.php @@ -191,6 +191,21 @@ class Pane extends UserWidget return implode("\n", $dashlets) . "\n"; } + /** + * Create, add and return a new dashlet + * + * @param string $title + * @param string $url + * + * @return Dashlet + */ + public function createDashlet($title, $url = null) + { + $dashlet = new Dashlet($title, $url, $this); + $this->addDashlet($dashlet); + return $dashlet; + } + /** * Add a dashlet to this pane, optionally creating it if $dashlet is a string * @@ -206,7 +221,7 @@ class Pane extends UserWidget if ($dashlet instanceof Dashlet) { $this->dashlets[$dashlet->getTitle()] = $dashlet; } elseif (is_string($dashlet) && $url !== null) { - $this->dashlets[$dashlet] = new Dashlet($dashlet, $url, $this); + $this->createDashlet($dashlet, $url); } else { throw new ConfigurationError('Invalid dashlet added: %s', $dashlet); }