create() ->orderBy('.sortOrder') ->paginate(1, 200); return $this->defaultRender($this->siteRequest->getPage()->getTemplate(), [ 'pager' => $pager, ]); } #[Route(path: '/mesh/download/{stlMesh}/{key}', name: 'mesh_download')] public function download(StlMesh $stlMesh, int $key): Response { $file = $stlMesh->getFiles()[--$key] ?? null; if (null === $file) { throw $this->createNotFoundException(); } $response = new BinaryFileResponse($file['file']); $response->setContentDisposition( ResponseHeaderBag::DISPOSITION_ATTACHMENT, sprintf('%s.stl', $file['name']) ); return $response; } #[Route(path: '/mesh/viewer/{stlMesh}/{key}', name: 'mesh_viewer')] public function viewer(StlMesh $stlMesh, int $key): Response { $file = $stlMesh->getFiles()[--$key] ?? null; if (null === $file) { throw $this->createNotFoundException(); } if (isset($file['htmlPreviewFile'])) { $file['htmlPreviewFile'] = file_get_contents($file['htmlPreviewFile']); } return $this->render('page/mesh/viewer.html.twig', [ 'mesh' => $stlMesh, 'file' => $file, 'key' => $key + 1, ]); } }