'Critic-Prompt', 'generate' => 'Generierungs-Prompt', 'revise' => 'Revisions-Prompt', 'system' => 'System-Prompt', 'other' => 'Sonstiges', ]; public function __construct(?ManagePromptsUseCase $promptsUseCase = null) { $this->promptsUseCase = $promptsUseCase ?? new ManagePromptsUseCase(); } public function index(): void { $this->view('prompts.index', [ 'title' => 'Prompts verwalten', 'prompts' => array_map(fn ($dto) => $dto->toArray(), $this->promptsUseCase->getAll()), 'stats' => $this->promptsUseCase->getStatistics(), 'promptTypes' => self::PROMPT_TYPES, ]); } public function promptsNew(): void { $this->view('prompts.form', [ 'title' => 'Neuer Prompt', 'prompt' => null, 'promptTypes' => self::PROMPT_TYPES, 'isEdit' => false, ]); } public function store(): void { $this->requireCsrf(); $result = $this->promptsUseCase->create( name: $_POST['name'] ?? '', version: $_POST['version'] ?? '1.0', content: $_POST['content'] ?? '', isActive: isset($_POST['is_active']) ); if (!$result->success) { $_SESSION['error'] = $result->message; header('Location: /prompts/new'); exit; } $_SESSION['success'] = $result->message; header('Location: /prompts/' . $result->id); exit; } public function show(string $id): void { $prompt = $this->promptsUseCase->getById((int) $id); if ($prompt === null) { $this->notFound('Prompt nicht gefunden'); } $this->view('prompts.show', [ 'title' => $prompt->name, 'prompt' => $prompt->toArray(), 'linkedCritics' => $this->promptsUseCase->getLinkedCritics((int) $id), 'promptTypes' => self::PROMPT_TYPES, ]); } public function edit(string $id): void { $prompt = $this->promptsUseCase->getById((int) $id); if ($prompt === null) { $this->notFound('Prompt nicht gefunden'); } $this->view('prompts.form', [ 'title' => 'Bearbeiten: ' . $prompt->name, 'prompt' => (array) $prompt, 'promptTypes' => self::PROMPT_TYPES, 'isEdit' => true, ]); } public function update(string $id): void { $this->requireCsrf(); $result = $this->promptsUseCase->update( id: (int) $id, name: $_POST['name'] ?? '', version: $_POST['version'] ?? '1.0', content: $_POST['content'] ?? '', isActive: isset($_POST['is_active']) ); if (!$result->success) { $_SESSION['error'] = $result->message; header('Location: /prompts/' . $id . '/edit'); exit; } $_SESSION['success'] = $result->message; header('Location: /prompts/' . $id); exit; } public function delete(string $id): void { $this->requireCsrf(); $result = $this->promptsUseCase->delete((int) $id); if (!$result->success) { $_SESSION['error'] = $result->message; header('Location: /prompts/' . $id); exit; } $_SESSION['success'] = $result->message; header('Location: /prompts'); exit; } public function duplicate(string $id): void { $this->requireCsrf(); $result = $this->promptsUseCase->duplicate((int) $id); if (!$result->success) { $_SESSION['error'] = $result->message; header('Location: /prompts/' . $id); exit; } $_SESSION['success'] = $result->message; header('Location: /prompts/' . $result->id . '/edit'); exit; } }