Piwik\DataTable::disableFilter PHP Метод

disableFilter() публичный Метод

Disable a specific filter to run on this DataTable in case you have already applied this filter or if you will handle this filter manually by using a custom filter. Be aware if you disable a given filter, that filter won't be ever executed. Even if another filter calls this filter on the DataTable.
public disableFilter ( string $className )
$className string eg 'Limit' or 'Sort'. Passing a `Closure` or an `array($class, $methodName)` is not supported yet. We check for exact match. So if you disable 'Limit' and call `->filter('Limit')` this filter won't be executed. If you call `->filter('Piwik\DataTable\Filter\Limit')` that filter will be executed. See it as a feature.
    public function disableFilter($className)
    {
        $this->disabledFilters[] = $className;
    }

Usage Example

Пример #1
0
 /**
  * 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));
 }