Piwik\API\DataTablePostProcessor::process PHP Метод

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

Apply post-processing logic to a DataTable of a report for an API request.
public process ( Piwik\DataTable\DataTableInterface $dataTable ) : Piwik\DataTable\DataTableInterface
$dataTable Piwik\DataTable\DataTableInterface The data table to process.
Результат Piwik\DataTable\DataTableInterface A new data table.
    public function process(DataTableInterface $dataTable)
    {
        // TODO: when calculating metrics before hand, only calculate for needed metrics, not all. NOTE:
        //       this is non-trivial since it will require, eg, to make sure processed metrics aren't added
        //       after pivotBy is handled.
        $dataTable = $this->applyPivotByFilter($dataTable);
        $dataTable = $this->applyTotalsCalculator($dataTable);
        $dataTable = $this->applyFlattener($dataTable);
        if ($this->callbackBeforeGenericFilters) {
            call_user_func($this->callbackBeforeGenericFilters, $dataTable);
        }
        $dataTable = $this->applyGenericFilters($dataTable);
        $this->applyComputeProcessedMetrics($dataTable);
        if ($this->callbackAfterGenericFilters) {
            call_user_func($this->callbackAfterGenericFilters, $dataTable);
        }
        // we automatically safe decode all datatable labels (against xss)
        $dataTable->queueFilter('SafeDecodeLabel');
        $dataTable = $this->convertSegmentValueToSegment($dataTable);
        $dataTable = $this->applyQueuedFilters($dataTable);
        $dataTable = $this->applyRequestedColumnDeletion($dataTable);
        $dataTable = $this->applyLabelFilter($dataTable);
        $dataTable = $this->applyMetricsFormatting($dataTable);
        return $dataTable;
    }

Usage Example

Пример #1
0
 private function handleDataTable(DataTableInterface $datatable)
 {
     if ($this->postProcessDataTable) {
         $postProcessor = new DataTablePostProcessor($this->apiModule, $this->apiMethod, $this->request);
         $datatable = $postProcessor->process($datatable);
     }
     return $this->apiRenderer->renderDataTable($datatable);
 }