canvasSlug = strip_tags((string) ($request->route('canvasSlug') ?? '')); $this->template = $templateRegistry->get($this->canvasSlug); } /** * get - generate and return the XML export file. * * @param string|null $canvasSlug Canvas type slug from the route (resolved in the constructor) * @param string|null $id Board id from the route */ #[RequiresPermission(BlueprintsPermissions::VIEW, entityScoped: true)] public function get(?string $canvasSlug = null, ?string $id = null): Response { if ($this->template === null) { return new Response('Unknown canvas type', 404); } // Resolve the board id from the route/query, falling back to the session. $sessionKey = $this->template->getSessionKey(); if ($id !== null && $id !== '') { $canvasId = (int) $id; } elseif (session()->exists($sessionKey)) { $canvasId = (int) session($sessionKey); } else { return new Response('', 204); } $exportData = $this->exportService->exportToXml($canvasId, $this->canvasSlug); if ($exportData === null) { return new Response('Canvas not found', 404); } clearstatcache(); $response = new Response($exportData); $response->headers->set('Content-type', 'application/xml'); $response->headers->set( 'Content-Disposition', 'attachment; filename="'.$this->template->getDatabaseType().'-'.$canvasId.'.xml"' ); $response->headers->set('Cache-Control', 'no-cache'); return $response; } }