Pane: Add method createDashlet()

refs #8848
This commit is contained in:
Johannes Meyer 2015-08-24 12:35:38 +02:00
parent 675a130787
commit db4c81a093
1 changed files with 16 additions and 1 deletions

View File

@ -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);
}