private function renderList(array $list, $namedRangeName)
 {
     $this->logger->debug("Rendering list {$namedRangeName}");
     $canvas = new Canvas($this->logger);
     foreach ($list as $item) {
         $itemCanvas = $this->renderItem($item, $namedRangeName);
         $this->rendererRepository->getRendererForNode($namedRangeName)->render($itemCanvas, $canvas);
     }
     return $canvas;
 }
 protected function setUp()
 {
     $logger = new Logger('rendertest');
     $logger->pushHandler(new StreamHandler('php://stdout', Logger::DEBUG));
     $rendererRepository = new RendererRepository();
     $rendererRepository->add(RendererInterface::ORIENTATION_VERTICAL, new VerticalRenderer());
     $rendererRepository->add(RendererInterface::ORIENTATION_HORIZONTAL, new HorizontalRenderer());
     $targetRepo = new ExcelFileRepository('tests/metadata/output');
     $this->templateRepo = new ExcelFileRepository('tests/metadata/template');
     $this->sut = new ExcelReportWriter($targetRepo, $this->templateRepo, $rendererRepository, $logger);
 }
 public function write(array $reportData, ReportConfig $reportConfig)
 {
     //TODO metadata is a hack. Refactor the whole template repository idea to support metadata related
     //to the template file (like horizontal/vertical render style, etc)
     $templateConfig = $this->templateRepository->getMetadata($reportConfig->getTemplateId());
     $this->rendererRepository->setConfig($templateConfig ? $templateConfig : []);
     $template = $this->templateRepository->get($reportConfig->getTemplateId());
     $canvasWriter = new ExcelCanvasWriter($template, $this->logger);
     $rangePopulator = new ExcelNamedRangeTemplatePopulator($this->logger);
     $renderer = new ReportRenderer($this->rendererRepository, new ReportDataCompiler($this->logger), $rangePopulator->populate($canvasWriter->getTemplateSheet()), $this->logger);
     $canvas = $renderer->render($reportData);
     $output = $canvasWriter->write($canvas);
     return $this->targetRepository->save($output, $reportConfig->getId());
 }