From 0c9cf80a406d3b608b40671e6f0e5091730fd1a9 Mon Sep 17 00:00:00 2001 From: Thomas Steur Date: Tue, 8 Oct 2013 23:40:59 +0000 Subject: [PATCH] refs #4199 added method to get all reports with goal metrics, otherwise it appears twice in the hooks documentation --- plugins/Goals/Goals.php | 33 ++++++++++++++++----------------- 1 file changed, 16 insertions(+), 17 deletions(-) diff --git a/plugins/Goals/Goals.php b/plugins/Goals/Goals.php index 222516ec90b..76fe8056670 100644 --- a/plugins/Goals/Goals.php +++ b/plugins/Goals/Goals.php @@ -43,13 +43,8 @@ public function getInformation() static public function getReportsWithGoalMetrics() { - $dimensions = array(); + $dimensions = self::getAllReportsWithGoalMetrics(); - /** - * This event is triggered to define available goal segments. - * @matt - */ - Piwik_PostEvent('Goals.getReportsWithGoalMetrics', array(&$dimensions)); $dimensionsByGroup = array(); foreach ($dimensions as $dimension) { $group = $dimension['category']; @@ -339,17 +334,8 @@ public function getReportMetadata(&$reports, $info) unset($goalMetrics['nb_visits_converted']); - $reportsWithGoals = array(); - - /* - * Add the metricsGoal and processedMetricsGoal entry - * to all reports that have Goal segmentation - * - * @matt is this same event as triggered above? Do we need two names? Currently they appear twice in the - * generated documentation. Maybe we can create a private/protected function to trigger this event to have it - * defined only once? - */ - Piwik_PostEvent('Goals.getReportsWithGoalMetrics', array(&$reportsWithGoals)); + $reportsWithGoals = self::getAllReportsWithGoalMetrics(); + foreach ($reportsWithGoals as $reportWithGoals) { // Select this report from the API metadata array // and add the Goal metrics to it @@ -365,6 +351,19 @@ public function getReportMetadata(&$reports, $info) } } + static private function getAllReportsWithGoalMetrics() + { + $reportsWithGoals = array(); + + /* + * This event is triggered to define available goal segments. + * @matt + */ + Piwik_PostEvent('Goals.getReportsWithGoalMetrics', array(&$reportsWithGoals)); + + return $reportsWithGoals; + } + static public function getProductReportColumns() { return array(