public function Console::table in Site Audit 8.3
Theme a table.
File
- src/
Renderer/ Console.php, line 230
Class
Namespace
Drupal\site_audit\RendererCode
public function table($element, $section = FALSE) {
if ($section) {
$this->output
->writeln($this->formatter
->formatSection($section, $element['#title']));
}
// make sure the table headers and rows have no translatable objects
$headers = $element['#header'] ?: $element['headers'];
foreach ($headers as &$header) {
if (is_object($header)) {
$header = (string) $header;
}
}
$rows = $element['#rows'] ?: [];
if (!empty($rows)) {
if (isset($rows['attributes']) && isset($rows['attributes']['class'])) {
$class = $rows['attributes']['class'];
}
else {
$class = NULL;
}
foreach ($rows as &$row) {
if (isset($row['data'])) {
$row = $row['data'];
}
foreach ($row as &$cell) {
if (is_object($cell)) {
$cell = (string) $cell;
}
}
}
}
// Theme as a table.
$table = new Table($this->output);
$table
->setHeaders($headers)
->setRows($rows);
$this->output
->writeln($table
->render());
}