protected function renderTableElement(Element $tableEl, $config)
{
$rows = [];
$colNames = [];
foreach ($tableEl->query('.//col') as $colEl) {
$colNames[] = $colEl->getAttribute('label');
}
foreach ($tableEl->query('.//row') as $rowEl) {
$row = [];
$formatterParams = [];
foreach ($rowEl->query('./formatter-param') as $paramEl) {
$formatterParams[$paramEl->getAttribute('name')] = $paramEl->nodeValue;
}
foreach ($rowEl->query('.//cell') as $cellEl) {
$colName = $cellEl->getAttribute('name');
$value = $cellEl->nodeValue;
if ('' !== $value && $cellEl->hasAttribute('class')) {
$classes = explode(' ', $cellEl->getAttribute('class'));
$value = $this->formatter->applyClasses($classes, $value, $formatterParams);
}
$row[$colName] = $value;
}
$rows[] = $row;
}
$table = $this->createTable();
// style only supported in Symfony > 2.4
if (method_exists($table, 'setStyle')) {
$table->setStyle($config['table_style']);
}
$table->setHeaders($colNames);
$table->setRows($rows);
$this->renderTable($table);
$this->output->writeln('');
}