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

Returns the associated subtable, if one exists. Returns false if none exists.
public getSubtable ( ) : DataTable | boolean
Результат Piwik\DataTable | boolean
Пример #1
0
 /**
  * Filters a row's subtable, if one exists and is loaded in memory.
  *
  * @param Row $row The row whose subtable should be filter.
  */
 public function filterSubTable(Row $row)
 {
     if (!$this->enableRecursive) {
         return;
     }
     $subTable = $row->getSubtable();
     if ($subTable) {
         $this->filter($subTable);
     }
 }
Пример #2
0
 private function loadSubtable(DataTable $table, Row $row)
 {
     $idSubtable = $row->getIdSubDataTable();
     if ($idSubtable === null) {
         return null;
     }
     $subtable = $row->getSubtable();
     if (!$subtable) {
         $subtable = $this->thisReport->fetchSubtable($idSubtable, $this->getRequestParamOverride($table));
     }
     if (!$subtable) {
         // sanity check
         throw new Exception("Unexpected error: could not load subtable '{$idSubtable}'.");
     }
     return $subtable;
 }
Пример #3
0
 /**
  * Helper function that tests if two rows are equal.
  *
  * Two rows are equal if:
  *
  * - they have exactly the same columns / metadata
  * - they have a subDataTable associated, then we check that both of them are the same.
  *
  * Column order is not important.
  *
  * @param \Piwik\DataTable\Row $row1 first to compare
  * @param \Piwik\DataTable\Row $row2 second to compare
  * @return bool
  */
 public static function isEqual(Row $row1, Row $row2)
 {
     //same columns
     $cols1 = $row1->getColumns();
     $cols2 = $row2->getColumns();
     $diff1 = array_udiff($cols1, $cols2, array(__CLASS__, 'compareElements'));
     $diff2 = array_udiff($cols2, $cols1, array(__CLASS__, 'compareElements'));
     if ($diff1 != $diff2) {
         return false;
     }
     $dets1 = $row1->getMetadata();
     $dets2 = $row2->getMetadata();
     ksort($dets1);
     ksort($dets2);
     if ($dets1 != $dets2) {
         return false;
     }
     // either both are null
     // or both have a value
     if (!(is_null($row1->getIdSubDataTable()) && is_null($row2->getIdSubDataTable()))) {
         $subtable1 = $row1->getSubtable();
         $subtable2 = $row2->getSubtable();
         if (!DataTable::isEqual($subtable1, $subtable2)) {
             return false;
         }
     }
     return true;
 }
Пример #4
0
 /**
  * @param Row $row
  * @param DataTable $dataTable
  * @param string $labelPrefix
  * @param bool $parentLogo
  */
 private function flattenRow(Row $row, $rowId, DataTable $dataTable, $labelPrefix = '', $parentLogo = false)
 {
     $label = $row->getColumn('label');
     if ($label !== false) {
         $label = trim($label);
         if ($this->recursiveLabelSeparator == '/') {
             if (substr($label, 0, 1) == '/') {
                 $label = substr($label, 1);
             } elseif ($rowId === DataTable::ID_SUMMARY_ROW && $labelPrefix && $label != DataTable::LABEL_SUMMARY_ROW) {
                 $label = ' - ' . $label;
             }
         }
         $label = $labelPrefix . $label;
         $row->setColumn('label', $label);
     }
     $logo = $row->getMetadata('logo');
     if ($logo === false && $parentLogo !== false) {
         $logo = $parentLogo;
         $row->setMetadata('logo', $logo);
     }
     /** @var DataTable $subTable */
     $subTable = $row->getSubtable();
     if ($subTable) {
         $subTable->applyQueuedFilters();
         $row->deleteMetadata('idsubdatatable_in_db');
     } else {
         $subTable = $this->loadSubtable($dataTable, $row);
     }
     $row->removeSubtable();
     if ($subTable === null) {
         if ($this->includeAggregateRows) {
             $row->setMetadata('is_aggregate', 0);
         }
         $dataTable->addRow($row);
     } else {
         if ($this->includeAggregateRows) {
             $row->setMetadata('is_aggregate', 1);
             $dataTable->addRow($row);
         }
         $prefix = $label . $this->recursiveLabelSeparator;
         $this->flattenDataTableInto($subTable, $dataTable, $prefix, $logo);
     }
 }