templateRepository = $templateRepository; } public function list(): array { $templates = $this->templateRepository->list(); $view = []; if (!empty($templates)) { foreach ($templates as $template) { $view[] = new TemplatesView( $template->getId(), $template->getName() ); } } return $view; } public function listTemplatesByExport(int $exportId): array { $templates = $this->templateRepository->listByTwigsExport($exportId); $result = []; if (!empty($templates)) { $result = $this->templateView($templates); } return $result; } public function listTemplatesByExports(array $exportsIds): array { $templates = $this->templateRepository->listByExportsIds($exportsIds); $result = []; if (!empty($templates)) { $result = $this->templateView($templates); } return $result; } private function templateView(array $templates) { $view = []; foreach ($templates as $template) { $exportType = $template->getTwig()->getExportType(); $view[$exportType][] = new TemplatesView( $template->getId(), $template->getName() ); } return $view; } }