Piwik\DataTable::filter PHP 메소드

filter() 공개 메소드

If {@link enableRecursiveFilters()} was called, the filter will be applied to all subtables as well.
public filter ( string | Closur\Closure $className, array $parameters = [] )
$className string | Closur\Closure Class name, eg. `"Sort"` or "Piwik\DataTable\Filters\Sort"`. If no namespace is supplied, `Piwik\DataTable\BaseFilter` is assumed. This parameter can also be a closure that takes a DataTable as its first parameter.
$parameters array Array of extra parameters to pass to the filter.
    public function filter($className, $parameters = array())
    {
        if ($className instanceof \Closure || is_array($className)) {
            array_unshift($parameters, $this);
            call_user_func_array($className, $parameters);
            return;
        }
        if (in_array($className, $this->disabledFilters)) {
            return;
        }
        if (!class_exists($className, true)) {
            $className = 'Piwik\\DataTable\\Filter\\' . $className;
        }
        $reflectionObj = new ReflectionClass($className);
        // the first parameter of a filter is the DataTable
        // we add the current datatable as the parameter
        $parameters = array_merge(array($this), $parameters);
        $filter = $reflectionObj->newInstanceArgs($parameters);
        $filter->enableRecursive($this->enableRecursiveFilters);
        $filter->filter($this);
    }

Usage Example

 public function test_filter_shouldIgnoreSummaryRow()
 {
     $row = $this->buildRow(array('label' => 'other'));
     $this->table->addSummaryRow($row);
     $this->table->filter($this->filter, array('UTC', 'day', 'today'));
     $this->assertFalse($row->getMetadata('segmentValue'));
 }
All Usage Examples Of Piwik\DataTable::filter