/** * @param $data * @return DataTable\Simple */ private function makeFromMetricsArray($data) { $table = new DataTable\Simple(); if (!empty($data)) { $table->setAllTableMetadata(DataCollection::getDataRowMetadata($data)); DataCollection::removeMetadataFromDataRow($data); $table->addRow(new Row(array(Row::COLUMNS => $data))); } else { // if we're querying numeric data, we couldn't find any, and we're only // looking for one metric, add a row w/ one column w/ value 0. this is to // ensure that the PHP renderer outputs 0 when only one column is queried. // w/o this code, an empty array would be created, and other parts of Piwik // would break. if (count($this->dataNames) == 1 && $this->dataType == 'numeric') { $name = reset($this->dataNames); $table->addRow(new Row(array(Row::COLUMNS => array($name => 0)))); } } $result = $table; return $result; }