setSubtable() public method

Attaches a subtable to this row, overwriting the existing subtable, if any.
public setSubtable ( DataTable $subTable ) : DataTable
$subTable Piwik\DataTable DataTable to associate to this row.
return Piwik\DataTable Returns `$subTable`.
 /**
  * @group Core
  */
 public function testSubDataTableIsDestructed()
 {
     $mockedDataTable = $this->getMock('\\Piwik\\DataTable', array('__destruct'));
     $mockedDataTable->expects($this->once())->method('__destruct');
     $rowBeingDestructed = new Row();
     $rowBeingDestructed->setSubtable($mockedDataTable);
     Common::destroy($rowBeingDestructed);
 }
Beispiel #2
0
 private function generateDataTableWithManySubtables($numSubtables)
 {
     $dataTable = new DataTable();
     for ($i = 1; $i <= $numSubtables; $i++) {
         $row = new Row(array(Row::COLUMNS => array('label' => 'Label Test ' . $i, 'nb_visits' => $i)));
         $subtable = DataTable::makeFromSimpleArray(array(array('label' => 'subtable' . $i, 'nb_visits' => $i)));
         $row->setSubtable($subtable);
         $dataTable->addRow($row);
     }
     return $dataTable->getSerialized();
 }
 private function getTableToFilter($addSubtables = false)
 {
     $row1 = new Row(array(Row::COLUMNS => array('label' => 'row 1', 'nb_visits' => 10, 'nb_actions' => 15)));
     if ($addSubtables) {
         $row1->setSubtable($this->getRow1Subtable());
     }
     $row2 = new Row(array(Row::COLUMNS => array('label' => 'row 2', 'nb_visits' => 13, 'nb_actions' => 18)));
     if ($addSubtables) {
         $row2->setSubtable($this->getRow2Subtable());
     }
     $row3 = new Row(array(Row::COLUMNS => array('label' => 'row 3', 'nb_visits' => 20, 'nb_actions' => 25)));
     if ($addSubtables) {
         $row3->setSubtable($this->getRow3Subtable());
     }
     $table = new DataTable();
     $table->addRowsFromArray(array($row1, $row2, $row3));
     return $table;
 }