method() !== 'POST') { throw new \Exception('This action requires POST.'); } } protected function requireAuth(): ?Response { if (!Sentinel::check()) { return $this->redirect('/login'); } return null; } protected function fileResponse(string $content, string $filename, string $mimeType = 'application/octet-stream'): Response { return new Response($content, 200, [ 'Content-Type' => $mimeType, 'Content-Disposition' => 'attachment; filename="' . $filename . '"', 'Content-Length' => (string) strlen($content), ]); } }