public applyGenericFilters ( Piwik\DataTable\DataTableInterface $dataTable ) : Piwik\DataTable\DataTableInterface | ||
$dataTable | Piwik\DataTable\DataTableInterface | |
return | Piwik\DataTable\DataTableInterface |
/** * Makes sure to not have any subtables anymore. * * So if $table is * array( * site1 * site2 * subtable => site3 * site4 * site5 * site6 * site7 * ) * * it will return * * array( * site1 * site2 * site3 * site4 * site5 * site6 * site7 * ) * * in a sorted order * * @param DataTable $table * @param array $request */ private function makeSitesFlatAndApplyGenericFilters(DataTable $table, $request) { // we handle limit here as we have to apply sort filter, then make sites flat, then apply limit filter. $filterOffset = $request['filter_offset']; $filterLimit = $request['filter_limit']; unset($request['filter_offset']); unset($request['filter_limit']); // filter_sort_column does not work correctly is a bug in MultiSites.getAll if (!empty($request['filter_sort_column']) && $request['filter_sort_column'] === 'nb_pageviews') { $request['filter_sort_column'] = 'Actions_nb_pageviews'; } elseif (!empty($request['filter_sort_column']) && $request['filter_sort_column'] === 'revenue') { $request['filter_sort_column'] = 'Goal_revenue'; } // make sure no limit filter is applied, we will do this manually $table->disableFilter('Limit'); // this will apply the sort filter /** @var DataTable $table */ $genericFilter = new DataTablePostProcessor('MultiSites', 'getAll', $request); $table = $genericFilter->applyGenericFilters($table); // make sure from now on the sites will be no longer sorted, they were already sorted $table->disableFilter('Sort'); // make sites flat and limit $table->filter('Piwik\\Plugins\\MultiSites\\DataTable\\Filter\\NestedSitesLimiter', array($filterOffset, $filterLimit)); }