{
"event": "PreToolUse",
"tool_name": "Edit",
"tool_input": {
"file_path": "\/var\/www\/dev.campus.systemische-tools.de\/src\/Controller\/PromptsController.php",
"old_string": "<?php\n\nnamespace Controller;\n\nuse Framework\\Controller;\nuse Infrastructure\\Persistence\\PromptsRepository;\n\nclass PromptsController extends Controller\n{\n private PromptsRepository $promptsRepo;\n\n private const PROMPT_TYPES = [\n 'critic' => 'Critic-Prompt',\n 'generate' => 'Generierungs-Prompt',\n 'revise' => 'Revisions-Prompt',\n 'system' => 'System-Prompt',\n 'other' => 'Sonstiges',\n ];\n\n public function __construct(?PromptsRepository $promptsRepo = null)\n {\n $this->promptsRepo = $promptsRepo ?? new PromptsRepository();\n }\n\n public function index(): void\n {\n $this->view('prompts.index', [\n 'title' => 'Prompts verwalten',\n 'prompts' => $this->promptsRepo->findAll(),\n 'stats' => $this->promptsRepo->getStatistics(),\n 'promptTypes' => self::PROMPT_TYPES,\n ]);\n }",
"new_string": "<?php\n\nnamespace Controller;\n\nuse Framework\\Controller;\nuse UseCases\\Prompts\\ManagePromptsUseCase;\n\nclass PromptsController extends Controller\n{\n private ManagePromptsUseCase $promptsUseCase;\n\n private const PROMPT_TYPES = [\n 'critic' => 'Critic-Prompt',\n 'generate' => 'Generierungs-Prompt',\n 'revise' => 'Revisions-Prompt',\n 'system' => 'System-Prompt',\n 'other' => 'Sonstiges',\n ];\n\n public function __construct(?ManagePromptsUseCase $promptsUseCase = null)\n {\n $this->promptsUseCase = $promptsUseCase ?? new ManagePromptsUseCase();\n }\n\n public function index(): void\n {\n $this->view('prompts.index', [\n 'title' => 'Prompts verwalten',\n 'prompts' => array_map(fn ($dto) => (array) $dto, $this->promptsUseCase->getAll()),\n 'stats' => $this->promptsUseCase->getStatistics(),\n 'promptTypes' => self::PROMPT_TYPES,\n ]);\n }"
}
}
{
"tool_response": {
"filePath": "\/var\/www\/dev.campus.systemische-tools.de\/src\/Controller\/PromptsController.php",
"oldString": "<?php\n\nnamespace Controller;\n\nuse Framework\\Controller;\nuse Infrastructure\\Persistence\\PromptsRepository;\n\nclass PromptsController extends Controller\n{\n private PromptsRepository $promptsRepo;\n\n private const PROMPT_TYPES = [\n 'critic' => 'Critic-Prompt',\n 'generate' => 'Generierungs-Prompt',\n 'revise' => 'Revisions-Prompt',\n 'system' => 'System-Prompt',\n 'other' => 'Sonstiges',\n ];\n\n public function __construct(?PromptsRepository $promptsRepo = null)\n {\n $this->promptsRepo = $promptsRepo ?? new PromptsRepository();\n }\n\n public function index(): void\n {\n $this->view('prompts.index', [\n 'title' => 'Prompts verwalten',\n 'prompts' => $this->promptsRepo->findAll(),\n 'stats' => $this->promptsRepo->getStatistics(),\n 'promptTypes' => self::PROMPT_TYPES,\n ]);\n }",
"newString": "<?php\n\nnamespace Controller;\n\nuse Framework\\Controller;\nuse UseCases\\Prompts\\ManagePromptsUseCase;\n\nclass PromptsController extends Controller\n{\n private ManagePromptsUseCase $promptsUseCase;\n\n private const PROMPT_TYPES = [\n 'critic' => 'Critic-Prompt',\n 'generate' => 'Generierungs-Prompt',\n 'revise' => 'Revisions-Prompt',\n 'system' => 'System-Prompt',\n 'other' => 'Sonstiges',\n ];\n\n public function __construct(?ManagePromptsUseCase $promptsUseCase = null)\n {\n $this->promptsUseCase = $promptsUseCase ?? new ManagePromptsUseCase();\n }\n\n public function index(): void\n {\n $this->view('prompts.index', [\n 'title' => 'Prompts verwalten',\n 'prompts' => array_map(fn ($dto) => (array) $dto, $this->promptsUseCase->getAll()),\n 'stats' => $this->promptsUseCase->getStatistics(),\n 'promptTypes' => self::PROMPT_TYPES,\n ]);\n }",
"originalFile": "<?php\n\nnamespace Controller;\n\nuse Framework\\Controller;\nuse Infrastructure\\Persistence\\PromptsRepository;\n\nclass PromptsController extends Controller\n{\n private PromptsRepository $promptsRepo;\n\n private const PROMPT_TYPES = [\n 'critic' => 'Critic-Prompt',\n 'generate' => 'Generierungs-Prompt',\n 'revise' => 'Revisions-Prompt',\n 'system' => 'System-Prompt',\n 'other' => 'Sonstiges',\n ];\n\n public function __construct(?PromptsRepository $promptsRepo = null)\n {\n $this->promptsRepo = $promptsRepo ?? new PromptsRepository();\n }\n\n public function index(): void\n {\n $this->view('prompts.index', [\n 'title' => 'Prompts verwalten',\n 'prompts' => $this->promptsRepo->findAll(),\n 'stats' => $this->promptsRepo->getStatistics(),\n 'promptTypes' => self::PROMPT_TYPES,\n ]);\n }\n\n public function promptsNew(): void\n {\n $this->view('prompts.form', [\n 'title' => 'Neuer Prompt',\n 'prompt' => null,\n 'promptTypes' => self::PROMPT_TYPES,\n 'isEdit' => false,\n ]);\n }\n\n public function store(): void\n {\n $this->requireCsrf();\n\n $name = trim($_POST['name'] ?? '');\n $version = trim($_POST['version'] ?? '1.0');\n $content = $_POST['content'] ?? '';\n $isActive = isset($_POST['is_active']) ? 1 : 0;\n\n if ($name === '' || $content === '') {\n $_SESSION['error'] = 'Name und Inhalt sind erforderlich.';\n header('Location: \/prompts\/new');\n exit;\n }\n\n $id = $this->promptsRepo->create($name, $version, $content, $isActive);\n\n $_SESSION['success'] = 'Prompt erfolgreich erstellt.';\n header('Location: \/prompts\/' . $id);\n exit;\n }\n\n public function show(string $id): void\n {\n $prompt = $this->promptsRepo->findById((int) $id);\n if ($prompt === null) {\n $this->notFound('Prompt nicht gefunden');\n }\n\n $this->view('prompts.show', [\n 'title' => $prompt['name'],\n 'prompt' => $prompt,\n 'linkedCritics' => $this->promptsRepo->findLinkedCritics((int) $id),\n 'promptTypes' => self::PROMPT_TYPES,\n ]);\n }\n\n public function edit(string $id): void\n {\n $prompt = $this->promptsRepo->findById((int) $id);\n if ($prompt === null) {\n $this->notFound('Prompt nicht gefunden');\n }\n\n $this->view('prompts.form', [\n 'title' => 'Bearbeiten: ' . $prompt['name'],\n 'prompt' => $prompt,\n 'promptTypes' => self::PROMPT_TYPES,\n 'isEdit' => true,\n ]);\n }\n\n public function update(string $id): void\n {\n $this->requireCsrf();\n\n $prompt = $this->promptsRepo->findById((int) $id);\n if ($prompt === null) {\n $this->notFound('Prompt nicht gefunden');\n }\n\n $name = trim($_POST['name'] ?? '');\n $version = trim($_POST['version'] ?? $prompt['version']);\n $content = $_POST['content'] ?? '';\n $isActive = isset($_POST['is_active']) ? 1 : 0;\n\n if ($name === '' || $content === '') {\n $_SESSION['error'] = 'Name und Inhalt sind erforderlich.';\n header('Location: \/prompts\/' . $id . '\/edit');\n exit;\n }\n\n $this->promptsRepo->update((int) $id, $name, $version, $content, $isActive);\n\n $_SESSION['success'] = 'Prompt aktualisiert.';\n header('Location: \/prompts\/' . $id);\n exit;\n }\n\n public function delete(string $id): void\n {\n $this->requireCsrf();\n\n $prompt = $this->promptsRepo->findById((int) $id);\n if ($prompt === null) {\n $this->notFound('Prompt nicht gefunden');\n }\n\n $criticCount = $this->promptsRepo->countLinkedCritics((int) $id);\n if ($criticCount > 0) {\n $_SESSION['error'] = \"Kann nicht gelöscht werden: {$criticCount} Critics verknüpft.\";\n header('Location: \/prompts\/' . $id);\n exit;\n }\n\n $this->promptsRepo->delete((int) $id);\n\n $_SESSION['success'] = 'Prompt gelöscht.';\n header('Location: \/prompts');\n exit;\n }\n\n public function duplicate(string $id): void\n {\n $this->requireCsrf();\n\n $prompt = $this->promptsRepo->findById((int) $id);\n if ($prompt === null) {\n $this->notFound('Prompt nicht gefunden');\n }\n\n $newName = $prompt['name'] . ' (Kopie)';\n $newId = $this->promptsRepo->duplicate((int) $id, $newName, '1.0');\n\n $_SESSION['success'] = 'Prompt dupliziert.';\n header('Location: \/prompts\/' . $newId . '\/edit');\n exit;\n }\n}\n",
"structuredPatch": [
{
"oldStart": 3,
"oldLines": 11,
"newStart": 3,
"newLines": 11,
"lines": [
" namespace Controller;",
" ",
" use Framework\\Controller;",
"-use Infrastructure\\Persistence\\PromptsRepository;",
"+use UseCases\\Prompts\\ManagePromptsUseCase;",
" ",
" class PromptsController extends Controller",
" {",
"- private PromptsRepository $promptsRepo;",
"+ private ManagePromptsUseCase $promptsUseCase;",
" ",
" private const PROMPT_TYPES = [",
" 'critic' => 'Critic-Prompt',"
]
},
{
"oldStart": 17,
"oldLines": 17,
"newStart": 17,
"newLines": 17,
"lines": [
" 'other' => 'Sonstiges',",
" ];",
" ",
"- public function __construct(?PromptsRepository $promptsRepo = null)",
"+ public function __construct(?ManagePromptsUseCase $promptsUseCase = null)",
" {",
"- $this->promptsRepo = $promptsRepo ?? new PromptsRepository();",
"+ $this->promptsUseCase = $promptsUseCase ?? new ManagePromptsUseCase();",
" }",
" ",
" public function index(): void",
" {",
" $this->view('prompts.index', [",
" 'title' => 'Prompts verwalten',",
"- 'prompts' => $this->promptsRepo->findAll(),",
"- 'stats' => $this->promptsRepo->getStatistics(),",
"+ 'prompts' => array_map(fn ($dto) => (array) $dto, $this->promptsUseCase->getAll()),",
"+ 'stats' => $this->promptsUseCase->getStatistics(),",
" 'promptTypes' => self::PROMPT_TYPES,",
" ]);",
" }"
]
}
],
"userModified": false,
"replaceAll": false
}
}