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

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

If {@link setMaximumAllowedRows()} was called and the current row count is at the maximum, the new row will be summed to the summary row. If there is no summary row, this row is set as the summary row.
public addRow ( Row $row ) : Row
$row Piwik\DataTable\Row
Результат Piwik\DataTable\Row `$row` or the summary row if we're at the maximum number of rows.
    public function addRow(Row $row)
    {
        // if there is a upper limit on the number of allowed rows and the table is full,
        // add the new row to the summary row
        if ($this->maximumAllowedRows > 0 && $this->getRowsCount() >= $this->maximumAllowedRows - 1) {
            if ($this->summaryRow === null) {
                // create the summary row if necessary
                $columns = array('label' => self::LABEL_SUMMARY_ROW) + $row->getColumns();
                $this->addSummaryRow(new Row(array(Row::COLUMNS => $columns)));
            } else {
                $this->summaryRow->sumRow($row, $enableCopyMetadata = false, $this->getMetadata(self::COLUMN_AGGREGATION_OPS_METADATA_NAME));
            }
            return $this->summaryRow;
        }
        $this->rows[] = $row;
        if (!$this->indexNotUpToDate && $this->rebuildIndexContinuously) {
            $label = $row->getColumn('label');
            if ($label !== false) {
                $this->rowsIndexByLabel[$label] = count($this->rows) - 1;
            }
        }
        return $row;
    }

Usage Example

 private function addRowWithMetadata($metadata)
 {
     $row = new Row(array(Row::COLUMNS => array('label' => 'val1')));
     foreach ($metadata as $name => $value) {
         $row->setMetadata($name, $value);
     }
     $this->table->addRow($row);
 }
All Usage Examples Of Piwik\DataTable::addRow