Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. Table.php

function Table::calculateColumnsWidth

Calculates columns widths.

1 call to Table::calculateColumnsWidth()
Table::render in vendor/symfony/console/Helper/Table.php
Renders table to output.

File

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

Class

Table
Provides helpers to display a table.

Namespace

Symfony\Component\Console\Helper

Code

private function calculateColumnsWidth(iterable $groups) : void {
    for ($column = 0; $column < $this->numberOfColumns; ++$column) {
        $lengths = [];
        foreach ($groups as $group) {
            foreach ($group as $row) {
                if ($row instanceof TableSeparator) {
                    continue;
                }
                foreach ($row as $i => $cell) {
                    if ($cell instanceof TableCell) {
                        $textContent = Helper::removeDecoration($this->output
                            ->getFormatter(), $cell);
                        $textLength = Helper::width($textContent);
                        if ($textLength > 0) {
                            $contentColumns = mb_str_split($textContent, ceil($textLength / $cell->getColspan()));
                            foreach ($contentColumns as $position => $content) {
                                $row[$i + $position] = $content;
                            }
                        }
                    }
                }
                $lengths[] = $this->getCellWidth($row, $column);
            }
        }
        $this->effectiveColumnWidths[$column] = max($lengths) + Helper::width($this->style
            ->getCellRowContentFormat()) - 2;
    }
}

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal