Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/matomo-org/matomo.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStefan Giehl <stefan@piwik.org>2018-06-14 00:05:12 +0300
committerdiosmosis <diosmosis@users.noreply.github.com>2018-06-14 00:05:12 +0300
commit8b5f334e0deb865af56a3b84133b7a7c1575bb1d (patch)
treeb61e2801da1f69a25ef673fdec3c16bc65e17d72 /core/Plugin/Report.php
parent8c7a50cb6738232c8da2042e4de14b13fd77eba9 (diff)
Allow to provide secondary sort column for reports (#12128)
* Allow to provide secondy sort column for reports * rename method * Adds two simple tests to prove secondary column sorting * invoke sort callback with datatable as second parameter
Diffstat (limited to 'core/Plugin/Report.php')
-rw-r--r--core/Plugin/Report.php27
1 files changed, 24 insertions, 3 deletions
diff --git a/core/Plugin/Report.php b/core/Plugin/Report.php
index c300ad11a3..e0850586d9 100644
--- a/core/Plugin/Report.php
+++ b/core/Plugin/Report.php
@@ -10,16 +10,13 @@ namespace Piwik\Plugin;
use Piwik\API\Proxy;
use Piwik\API\Request;
-use Piwik\Cache;
use Piwik\Columns\Dimension;
use Piwik\Common;
use Piwik\DataTable;
use Piwik\DataTable\Filter\Sort;
use Piwik\Metrics;
-use Piwik\Cache as PiwikCache;
use Piwik\Piwik;
use Piwik\Plugins\CoreVisualizations\Visualizations\HtmlTable;
-use Piwik\Plugins\CoreVisualizations\Visualizations\JqplotGraph\Evolution;
use Piwik\ViewDataTable\Factory as ViewDataTableFactory;
use Exception;
use Piwik\Widget\WidgetsList;
@@ -649,6 +646,30 @@ class Report
}
/**
+ * Allows to define a callback that will be used to determine the secondary column to sort by
+ *
+ * ```
+ * public function getSecondarySortColumnCallback()
+ * {
+ * return function ($primaryColumn) {
+ * switch ($primaryColumn) {
+ * case Metrics::NB_CLICKS:
+ * return Metrics::NB_IMPRESSIONS;
+ * case 'label':
+ * default:
+ * return Metrics::NB_CLICKS;
+ * }
+ * };
+ * }
+ * ```
+ * @return null|callable
+ */
+ public function getSecondarySortColumnCallback()
+ {
+ return null;
+ }
+
+ /**
* Get the list of related reports if there are any. They will be displayed for instance below a report as a
* recommended related report.
*