private function Table::fillNextRows in Zircon Profile 8.0
Same name and namespace in other branches
- 8 vendor/symfony/console/Helper/Table.php \Symfony\Component\Console\Helper\Table::fillNextRows()
fill rows that contains rowspan > 1.
Parameters
array $rows:
int $line:
Return value
array
1 call to Table::fillNextRows()
- Table::buildTableRows in vendor/
symfony/ console/ Helper/ Table.php
File
- vendor/
symfony/ console/ Helper/ Table.php, line 383
Class
- Table
- Provides helpers to display a table.
Namespace
Symfony\Component\Console\HelperCode
private function fillNextRows($rows, $line) {
$unmergedRows = array();
foreach ($rows[$line] as $column => $cell) {
if ($cell instanceof TableCell && $cell
->getRowspan() > 1) {
$nbLines = $cell
->getRowspan() - 1;
$lines = array(
$cell,
);
if (strstr($cell, "\n")) {
$lines = explode("\n", $cell);
$nbLines = count($lines) > $nbLines ? substr_count($cell, "\n") : $nbLines;
$rows[$line][$column] = new TableCell($lines[0], array(
'colspan' => $cell
->getColspan(),
));
unset($lines[0]);
}
// create a two dimensional array (rowspan x colspan)
$unmergedRows = array_replace_recursive(array_fill($line + 1, $nbLines, ''), $unmergedRows);
foreach ($unmergedRows as $unmergedRowKey => $unmergedRow) {
$value = isset($lines[$unmergedRowKey - $line]) ? $lines[$unmergedRowKey - $line] : '';
$unmergedRows[$unmergedRowKey][$column] = new TableCell($value, array(
'colspan' => $cell
->getColspan(),
));
}
}
}
foreach ($unmergedRows as $unmergedRowKey => $unmergedRow) {
// we need to know if $unmergedRow will be merged or inserted into $rows
if (isset($rows[$unmergedRowKey]) && is_array($rows[$unmergedRowKey]) && $this
->getNumberOfColumns($rows[$unmergedRowKey]) + $this
->getNumberOfColumns($unmergedRows[$unmergedRowKey]) <= $this->numberOfColumns) {
foreach ($unmergedRow as $cellKey => $cell) {
// insert cell into row at cellKey position
array_splice($rows[$unmergedRowKey], $cellKey, 0, array(
$cell,
));
}
}
else {
$row = $this
->copyRow($rows, $unmergedRowKey - 1);
foreach ($unmergedRow as $column => $cell) {
if (!empty($cell)) {
$row[$column] = $unmergedRow[$column];
}
}
array_splice($rows, $unmergedRowKey, 0, array(
$row,
));
}
}
return $rows;
}