From db4c81a09339be8b70b79e783f83a7bdec862e9e Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Mon, 24 Aug 2015 12:35:38 +0200 Subject: [PATCH] Pane: Add method createDashlet() refs #8848 --- library/Icinga/Web/Widget/Dashboard/Pane.php | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) 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); }