Piwik\DataTable::getRowFromLabel PHP Méthode

getRowFromLabel() public méthode

This method executes in constant time except for the first call which caches row label => row ID mappings.
public getRowFromLabel ( string $label ) : Row | false
$label string `'label'` column value to look for.
Résultat Piwik\DataTable\Row | false The row if found, `false` if otherwise.
    public function getRowFromLabel($label)
    {
        $rowId = $this->getRowIdFromLabel($label);
        if (is_int($rowId) && isset($this->rows[$rowId])) {
            return $this->rows[$rowId];
        }
        if ($rowId == self::ID_SUMMARY_ROW && !empty($this->summaryRow)) {
            return $this->summaryRow;
        }
        if ($rowId instanceof Row) {
            return $rowId;
        }
        return false;
    }

Usage Example

 /**
  * Method for the recursive descend
  *
  * @param array $labelParts
  * @param DataTable $dataTable
  * @return Row|bool
  */
 private function doFilterRecursiveDescend($labelParts, $dataTable)
 {
     // search for the first part of the tree search
     $labelPart = array_shift($labelParts);
     $row = false;
     foreach ($this->getLabelVariations($labelPart) as $labelPart) {
         $row = $dataTable->getRowFromLabel($labelPart);
         if ($row !== false) {
             break;
         }
     }
     if ($row === false) {
         // not found
         return false;
     }
     // end of tree search reached
     if (count($labelParts) == 0) {
         return $row;
     }
     $subTable = $this->loadSubtable($dataTable, $row);
     if ($subTable === null) {
         // no more subtables but label parts left => no match found
         return false;
     }
     return $this->doFilterRecursiveDescend($labelParts, $subTable);
 }
All Usage Examples Of Piwik\DataTable::getRowFromLabel