You are here

private function Table::buildTableRows in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 vendor/symfony/console/Helper/Table.php \Symfony\Component\Console\Helper\Table::buildTableRows()
1 call to Table::buildTableRows()
Table::render in vendor/symfony/console/Helper/Table.php
Renders table to output.

File

vendor/symfony/console/Helper/Table.php, line 338

Class

Table
Provides helpers to display a table.

Namespace

Symfony\Component\Console\Helper

Code

private function buildTableRows($rows) {
  $unmergedRows = array();
  for ($rowKey = 0; $rowKey < count($rows); ++$rowKey) {
    $rows = $this
      ->fillNextRows($rows, $rowKey);

    // Remove any new line breaks and replace it with a new line
    foreach ($rows[$rowKey] as $column => $cell) {
      $rows[$rowKey] = $this
        ->fillCells($rows[$rowKey], $column);
      if (!strstr($cell, "\n")) {
        continue;
      }
      $lines = explode("\n", $cell);
      foreach ($lines as $lineKey => $line) {
        if ($cell instanceof TableCell) {
          $line = new TableCell($line, array(
            'colspan' => $cell
              ->getColspan(),
          ));
        }
        if (0 === $lineKey) {
          $rows[$rowKey][$column] = $line;
        }
        else {
          $unmergedRows[$rowKey][$lineKey][$column] = $line;
        }
      }
    }
  }
  $tableRows = array();
  foreach ($rows as $rowKey => $row) {
    $tableRows[] = $row;
    if (isset($unmergedRows[$rowKey])) {
      $tableRows = array_merge($tableRows, $unmergedRows[$rowKey]);
    }
  }
  return $tableRows;
}