diff options
author | sgiehl <stefan@piwik.org> | 2014-11-22 22:39:27 +0300 |
---|---|---|
committer | sgiehl <stefan@piwik.org> | 2014-11-22 22:39:27 +0300 |
commit | 776584c2ab945bf5496f502f0e53c63e1a70a004 (patch) | |
tree | 7ff652356b5e7520b6627c273ec9d02e8cc213cf /core/WidgetsList.php | |
parent | 26188f9bdaa257a7608d0de2cfbde420dcf917dd (diff) |
moved logic for replacing a dashboard widget to dashboard model
Diffstat (limited to 'core/WidgetsList.php')
-rw-r--r-- | core/WidgetsList.php | 33 |
1 files changed, 24 insertions, 9 deletions
diff --git a/core/WidgetsList.php b/core/WidgetsList.php index e67f6b1b77..943dfceb68 100644 --- a/core/WidgetsList.php +++ b/core/WidgetsList.php @@ -159,18 +159,15 @@ class WidgetsList extends Singleton } /** - * Adds a report to the list of dashboard widgets. + * Returns the unique id of an widget with the given parameters * - * @param string $widgetCategory The widget category. This can be a translation token. - * @param string $widgetName The name of the widget. This can be a translation token. - * @param string $controllerName The report's controller name (same as the plugin name). - * @param string $controllerAction The report's controller action method name. - * @param array $customParameters Extra query parameters that should be sent while getting - * this report. + * @param $controllerName + * @param $controllerAction + * @param array $customParameters + * @return string */ - public static function add($widgetCategory, $widgetName, $controllerName, $controllerAction, $customParameters = array()) + public static function getWidgetUniqueId($controllerName, $controllerAction, $customParameters = array()) { - $widgetName = Piwik::translate($widgetName); $widgetUniqueId = 'widget' . $controllerName . $controllerAction; foreach ($customParameters as $name => $value) { @@ -182,6 +179,24 @@ class WidgetsList extends Singleton $widgetUniqueId .= $name . $value; } + return $widgetUniqueId; + } + + /** + * Adds a report to the list of dashboard widgets. + * + * @param string $widgetCategory The widget category. This can be a translation token. + * @param string $widgetName The name of the widget. This can be a translation token. + * @param string $controllerName The report's controller name (same as the plugin name). + * @param string $controllerAction The report's controller action method name. + * @param array $customParameters Extra query parameters that should be sent while getting + * this report. + */ + public static function add($widgetCategory, $widgetName, $controllerName, $controllerAction, $customParameters = array()) + { + $widgetName = Piwik::translate($widgetName); + $widgetUniqueId = self::getWidgetUniqueId($controllerName, $controllerAction, $customParameters); + if (!array_key_exists($widgetCategory, self::$widgets)) { self::$widgets[$widgetCategory] = array(); } |