/** * @inheritdoc */ public function write(OutputInterface $output, $tableTransformer, FormatterOptions $options) { $table = new Table($output); $table->setStyle('compact'); foreach ($tableTransformer as $rowid => $row) { $rowLabel = $tableTransformer->getRowLabel($rowid); $output->writeln(''); $output->writeln($rowLabel); $sectionData = new PropertyList($row); $sectionOptions = new FormatterOptions([], $options->getOptions()); $sectionTableTransformer = $sectionData->restructure($sectionOptions); $table->setRows($sectionTableTransformer->getTableData(true)); $table->render(); } }
protected function associativeListWithRenderer() { $data = ['one' => 'apple', 'two' => ['banana', 'plantain'], 'three' => 'carrot', 'four' => ['peaches', 'pumpkin pie']]; $list = new PropertyList($data); $list->addRendererFunction(function ($key, $cellData, FormatterOptions $options) { if (is_array($cellData)) { return implode(',', $cellData); } return $cellData; }); return $list; }