{
"event": "PreToolUse",
"tool_name": "Edit",
"tool_input": {
"file_path": "\/var\/www\/dev.campus.systemische-tools.de\/src\/Controller\/StopwordController.php",
"old_string": " public function delete(string $id): void\n {\n $this->requireCsrf();\n\n $stopword = $this->repo->find((int) $id);\n if ($stopword === null) {\n $this->notFound('Stopword nicht gefunden');\n }\n\n $this->repo->delete((int) $id);\n\n $_SESSION['success'] = \"Stopword '{$stopword['word']}' wurde geloescht.\";\n $this->redirect('\/semantic-explorer\/stopwords');\n }\n\n public function toggle(string $id): void\n {\n $this->requireCsrf();\n\n $stopword = $this->repo->find((int) $id);\n if ($stopword === null) {\n $this->notFound('Stopword nicht gefunden');\n }\n\n $this->repo->toggleActive((int) $id);\n\n $newState = $stopword['is_active'] ? 'deaktiviert' : 'aktiviert';\n $_SESSION['success'] = \"Stopword '{$stopword['word']}' wurde {$newState}.\";\n $this->redirect('\/semantic-explorer\/stopwords');\n }\n}",
"new_string": " public function delete(string $id): void\n {\n $this->requireCsrf();\n\n $stopword = $this->repo->find((int) $id);\n if ($stopword === null) {\n $this->notFound('Stopword nicht gefunden');\n }\n\n $this->repo->delete((int) $id);\n\n if ($this->isHtmxRequest()) {\n $this->htmxRedirect('\/semantic-explorer\/stopwords');\n\n return;\n }\n\n $_SESSION['success'] = \"Stopword '{$stopword['word']}' wurde geloescht.\";\n $this->redirect('\/semantic-explorer\/stopwords');\n }\n\n public function toggle(string $id): void\n {\n $this->requireCsrf();\n\n $stopword = $this->repo->find((int) $id);\n if ($stopword === null) {\n $this->notFound('Stopword nicht gefunden');\n }\n\n $this->repo->toggleActive((int) $id);\n\n if ($this->isHtmxRequest()) {\n $this->htmxRedirect('\/semantic-explorer\/stopwords');\n\n return;\n }\n\n $newState = $stopword['is_active'] ? 'deaktiviert' : 'aktiviert';\n $_SESSION['success'] = \"Stopword '{$stopword['word']}' wurde {$newState}.\";\n $this->redirect('\/semantic-explorer\/stopwords');\n }\n}"
}
}
{
"tool_response": {
"filePath": "\/var\/www\/dev.campus.systemische-tools.de\/src\/Controller\/StopwordController.php",
"oldString": " public function delete(string $id): void\n {\n $this->requireCsrf();\n\n $stopword = $this->repo->find((int) $id);\n if ($stopword === null) {\n $this->notFound('Stopword nicht gefunden');\n }\n\n $this->repo->delete((int) $id);\n\n $_SESSION['success'] = \"Stopword '{$stopword['word']}' wurde geloescht.\";\n $this->redirect('\/semantic-explorer\/stopwords');\n }\n\n public function toggle(string $id): void\n {\n $this->requireCsrf();\n\n $stopword = $this->repo->find((int) $id);\n if ($stopword === null) {\n $this->notFound('Stopword nicht gefunden');\n }\n\n $this->repo->toggleActive((int) $id);\n\n $newState = $stopword['is_active'] ? 'deaktiviert' : 'aktiviert';\n $_SESSION['success'] = \"Stopword '{$stopword['word']}' wurde {$newState}.\";\n $this->redirect('\/semantic-explorer\/stopwords');\n }\n}",
"newString": " public function delete(string $id): void\n {\n $this->requireCsrf();\n\n $stopword = $this->repo->find((int) $id);\n if ($stopword === null) {\n $this->notFound('Stopword nicht gefunden');\n }\n\n $this->repo->delete((int) $id);\n\n if ($this->isHtmxRequest()) {\n $this->htmxRedirect('\/semantic-explorer\/stopwords');\n\n return;\n }\n\n $_SESSION['success'] = \"Stopword '{$stopword['word']}' wurde geloescht.\";\n $this->redirect('\/semantic-explorer\/stopwords');\n }\n\n public function toggle(string $id): void\n {\n $this->requireCsrf();\n\n $stopword = $this->repo->find((int) $id);\n if ($stopword === null) {\n $this->notFound('Stopword nicht gefunden');\n }\n\n $this->repo->toggleActive((int) $id);\n\n if ($this->isHtmxRequest()) {\n $this->htmxRedirect('\/semantic-explorer\/stopwords');\n\n return;\n }\n\n $newState = $stopword['is_active'] ? 'deaktiviert' : 'aktiviert';\n $_SESSION['success'] = \"Stopword '{$stopword['word']}' wurde {$newState}.\";\n $this->redirect('\/semantic-explorer\/stopwords');\n }\n}",
"originalFile": "<?php\n\ndeclare(strict_types=1);\n\nnamespace Controller;\n\n\/\/ @responsibility: HTTP-Endpunkte für Stopword-Verwaltung (Entity-Extraction Filter)\n\nuse Domain\\Repository\\StopwordRepositoryInterface;\nuse Framework\\Controller;\n\nclass StopwordController extends Controller\n{\n private StopwordRepositoryInterface $repo;\n\n public function __construct(StopwordRepositoryInterface $repo)\n {\n $this->repo = $repo;\n }\n\n public function index(): void\n {\n $category = $this->getString('category');\n $showAll = $this->getString('all') === '1';\n\n $this->view('semantic-explorer.stopwords.index', [\n 'title' => 'Stopwords - Semantic Explorer',\n 'stopwords' => $this->repo->findAll(!$showAll, $category ?: null),\n 'stats' => $this->repo->getStats(),\n 'currentCategory' => $category,\n 'showAll' => $showAll,\n ]);\n }\n\n public function create(): void\n {\n $this->view('semantic-explorer.stopwords.new', [\n 'title' => 'Neues Stopword - Semantic Explorer',\n ]);\n }\n\n public function store(): void\n {\n $this->requireCsrf();\n\n $word = trim($this->getString('word'));\n if ($word === '') {\n if ($this->isHtmxRequest()) {\n $this->htmxError('Wort darf nicht leer sein.');\n\n return;\n }\n $_SESSION['error'] = 'Wort darf nicht leer sein.';\n $this->redirect('\/semantic-explorer\/stopwords\/new');\n }\n\n try {\n $id = $this->repo->create([\n 'word' => $word,\n 'category' => $this->getString('category') ?: 'generic',\n 'reason' => $this->getString('reason') ?: null,\n 'is_active' => isset($_POST['is_active']) ? 1 : 0,\n ]);\n\n if ($this->isHtmxRequest()) {\n $this->htmxRedirect('\/semantic-explorer\/stopwords\/' . $id);\n\n return;\n }\n\n $_SESSION['success'] = \"Stopword '{$word}' wurde erstellt.\";\n $this->redirect('\/semantic-explorer\/stopwords\/' . $id);\n } catch (\\PDOException $e) {\n $errorMsg = str_contains($e->getMessage(), 'Duplicate')\n ? \"Stopword '{$word}' existiert bereits.\"\n : 'Fehler beim Speichern: ' . $e->getMessage();\n\n if ($this->isHtmxRequest()) {\n $this->htmxError($errorMsg);\n\n return;\n }\n\n $_SESSION['error'] = $errorMsg;\n $this->redirect('\/semantic-explorer\/stopwords\/new');\n }\n }\n\n public function show(string $id): void\n {\n $stopword = $this->repo->find((int) $id);\n if ($stopword === null) {\n $this->notFound('Stopword nicht gefunden');\n }\n\n $this->view('semantic-explorer.stopwords.edit', [\n 'title' => 'Stopword: ' . $stopword['word'],\n 'stopword' => $stopword,\n ]);\n }\n\n public function update(string $id): void\n {\n $this->requireCsrf();\n\n $stopword = $this->repo->find((int) $id);\n if ($stopword === null) {\n $this->notFound('Stopword nicht gefunden');\n }\n\n $word = trim($this->getString('word'));\n if ($word === '') {\n if ($this->isHtmxRequest()) {\n $this->htmxError('Wort darf nicht leer sein.');\n\n return;\n }\n $_SESSION['error'] = 'Wort darf nicht leer sein.';\n $this->redirect('\/semantic-explorer\/stopwords\/' . $id);\n }\n\n try {\n $this->repo->update((int) $id, [\n 'word' => $word,\n 'category' => $this->getString('category') ?: 'generic',\n 'reason' => $this->getString('reason') ?: null,\n 'is_active' => isset($_POST['is_active']) ? 1 : 0,\n ]);\n\n if ($this->isHtmxRequest()) {\n $this->htmxRedirect('\/semantic-explorer\/stopwords\/' . $id);\n\n return;\n }\n\n $_SESSION['success'] = 'Stopword wurde aktualisiert.';\n $this->redirect('\/semantic-explorer\/stopwords\/' . $id);\n } catch (\\PDOException $e) {\n $errorMsg = str_contains($e->getMessage(), 'Duplicate')\n ? \"Stopword '{$word}' existiert bereits.\"\n : 'Fehler beim Speichern: ' . $e->getMessage();\n\n if ($this->isHtmxRequest()) {\n $this->htmxError($errorMsg);\n\n return;\n }\n\n $_SESSION['error'] = $errorMsg;\n $this->redirect('\/semantic-explorer\/stopwords\/' . $id);\n }\n }\n\n public function delete(string $id): void\n {\n $this->requireCsrf();\n\n $stopword = $this->repo->find((int) $id);\n if ($stopword === null) {\n $this->notFound('Stopword nicht gefunden');\n }\n\n $this->repo->delete((int) $id);\n\n $_SESSION['success'] = \"Stopword '{$stopword['word']}' wurde geloescht.\";\n $this->redirect('\/semantic-explorer\/stopwords');\n }\n\n public function toggle(string $id): void\n {\n $this->requireCsrf();\n\n $stopword = $this->repo->find((int) $id);\n if ($stopword === null) {\n $this->notFound('Stopword nicht gefunden');\n }\n\n $this->repo->toggleActive((int) $id);\n\n $newState = $stopword['is_active'] ? 'deaktiviert' : 'aktiviert';\n $_SESSION['success'] = \"Stopword '{$stopword['word']}' wurde {$newState}.\";\n $this->redirect('\/semantic-explorer\/stopwords');\n }\n}\n",
"structuredPatch": [
{
"oldStart": 162,
"oldLines": 6,
"newStart": 162,
"newLines": 12,
"lines": [
" ",
" $this->repo->delete((int) $id);",
" ",
"+ if ($this->isHtmxRequest()) {",
"+ $this->htmxRedirect('\/semantic-explorer\/stopwords');",
"+",
"+ return;",
"+ }",
"+",
" $_SESSION['success'] = \"Stopword '{$stopword['word']}' wurde geloescht.\";",
" $this->redirect('\/semantic-explorer\/stopwords');",
" }"
]
},
{
"oldStart": 177,
"oldLines": 6,
"newStart": 183,
"newLines": 12,
"lines": [
" ",
" $this->repo->toggleActive((int) $id);",
" ",
"+ if ($this->isHtmxRequest()) {",
"+ $this->htmxRedirect('\/semantic-explorer\/stopwords');",
"+",
"+ return;",
"+ }",
"+",
" $newState = $stopword['is_active'] ? 'deaktiviert' : 'aktiviert';",
" $_SESSION['success'] = \"Stopword '{$stopword['word']}' wurde {$newState}.\";",
" $this->redirect('\/semantic-explorer\/stopwords');"
]
}
],
"userModified": false,
"replaceAll": false
}
}