{
"tool_response": {
"type": "update",
"filePath": "\/var\/www\/dev.campus.systemische-tools.de\/src\/Controller\/StopwordController.php",
"content": "<?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 $_SESSION['error'] = 'Wort darf nicht leer sein.';\n $this->redirect('\/semantic-explorer\/stopwords\/new');\n\n return;\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 $_SESSION['success'] = \"Stopword '{$word}' wurde erstellt.\";\n $this->redirect('\/semantic-explorer\/stopwords\/' . $id);\n } catch (\\PDOException $e) {\n if (str_contains($e->getMessage(), 'Duplicate')) {\n $_SESSION['error'] = \"Stopword '{$word}' existiert bereits.\";\n } else {\n $_SESSION['error'] = 'Fehler beim Speichern: ' . $e->getMessage();\n }\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 return;\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 return;\n }\n\n $word = trim($this->getString('word'));\n if ($word === '') {\n $_SESSION['error'] = 'Wort darf nicht leer sein.';\n $this->redirect('\/semantic-explorer\/stopwords\/' . $id);\n\n return;\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 $_SESSION['success'] = 'Stopword wurde aktualisiert.';\n $this->redirect('\/semantic-explorer\/stopwords\/' . $id);\n } catch (\\PDOException $e) {\n if (str_contains($e->getMessage(), 'Duplicate')) {\n $_SESSION['error'] = \"Stopword '{$word}' existiert bereits.\";\n } else {\n $_SESSION['error'] = 'Fehler beim Speichern: ' . $e->getMessage();\n }\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 return;\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 return;\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": 23,
"oldLines": 8,
"newStart": 23,
"newLines": 8,
"lines": [
" $category = $this->getString('category');",
" $showAll = $this->getString('all') === '1';",
" ",
"- $this->view('stopwords.index', [",
"- 'title' => 'Stopwords verwalten',",
"+ $this->view('semantic-explorer.stopwords.index', [",
"+ 'title' => 'Stopwords - Semantic Explorer',",
" 'stopwords' => $this->repo->findAll(!$showAll, $category ?: null),",
" 'stats' => $this->repo->getStats(),",
" 'currentCategory' => $category,"
]
},
{
"oldStart": 32,
"oldLines": 12,
"newStart": 32,
"newLines": 10,
"lines": [
" ]);",
" }",
" ",
"- public function stopwordsNew(): void",
"+ public function create(): void",
" {",
"- $this->view('stopwords.form', [",
"- 'title' => 'Neues Stopword',",
"- 'stopword' => null,",
"- 'isEdit' => false,",
"+ $this->view('semantic-explorer.stopwords.new', [",
"+ 'title' => 'Neues Stopword - Semantic Explorer',",
" ]);",
" }",
" "
]
},
{
"oldStart": 48,
"oldLines": 7,
"newStart": 46,
"newLines": 9,
"lines": [
" $word = trim($this->getString('word'));",
" if ($word === '') {",
" $_SESSION['error'] = 'Wort darf nicht leer sein.';",
"- $this->redirect('\/stopwords\/new');",
"+ $this->redirect('\/semantic-explorer\/stopwords\/new');",
"+",
"+ return;",
" }",
" ",
" try {"
]
},
{
"oldStart": 60,
"oldLines": 14,
"newStart": 60,
"newLines": 14,
"lines": [
" ]);",
" ",
" $_SESSION['success'] = \"Stopword '{$word}' wurde erstellt.\";",
"- $this->redirect('\/stopwords\/' . $id);",
"+ $this->redirect('\/semantic-explorer\/stopwords\/' . $id);",
" } catch (\\PDOException $e) {",
" if (str_contains($e->getMessage(), 'Duplicate')) {",
" $_SESSION['error'] = \"Stopword '{$word}' existiert bereits.\";",
" } else {",
" $_SESSION['error'] = 'Fehler beim Speichern: ' . $e->getMessage();",
" }",
"- $this->redirect('\/stopwords\/new');",
"+ $this->redirect('\/semantic-explorer\/stopwords\/new');",
" }",
" }",
" "
]
},
{
"oldStart": 76,
"oldLines": 12,
"newStart": 76,
"newLines": 13,
"lines": [
" $stopword = $this->repo->find((int) $id);",
" if ($stopword === null) {",
" $this->notFound('Stopword nicht gefunden');",
"+",
"+ return;",
" }",
" ",
"- $this->view('stopwords.form', [",
"+ $this->view('semantic-explorer.stopwords.edit', [",
" 'title' => 'Stopword: ' . $stopword['word'],",
" 'stopword' => $stopword,",
"- 'isEdit' => true,",
" ]);",
" }",
" "
]
},
{
"oldStart": 92,
"oldLines": 12,
"newStart": 93,
"newLines": 16,
"lines": [
" $stopword = $this->repo->find((int) $id);",
" if ($stopword === null) {",
" $this->notFound('Stopword nicht gefunden');",
"+",
"+ return;",
" }",
" ",
" $word = trim($this->getString('word'));",
" if ($word === '') {",
" $_SESSION['error'] = 'Wort darf nicht leer sein.';",
"- $this->redirect('\/stopwords\/' . $id);",
"+ $this->redirect('\/semantic-explorer\/stopwords\/' . $id);",
"+",
"+ return;",
" }",
" ",
" try {"
]
},
{
"oldStart": 109,
"oldLines": 14,
"newStart": 114,
"newLines": 14,
"lines": [
" ]);",
" ",
" $_SESSION['success'] = 'Stopword wurde aktualisiert.';",
"- $this->redirect('\/stopwords\/' . $id);",
"+ $this->redirect('\/semantic-explorer\/stopwords\/' . $id);",
" } catch (\\PDOException $e) {",
" if (str_contains($e->getMessage(), 'Duplicate')) {",
" $_SESSION['error'] = \"Stopword '{$word}' existiert bereits.\";",
" } else {",
" $_SESSION['error'] = 'Fehler beim Speichern: ' . $e->getMessage();",
" }",
"- $this->redirect('\/stopwords\/' . $id);",
"+ $this->redirect('\/semantic-explorer\/stopwords\/' . $id);",
" }",
" }",
" "
]
},
{
"oldStart": 127,
"oldLines": 12,
"newStart": 132,
"newLines": 14,
"lines": [
" $stopword = $this->repo->find((int) $id);",
" if ($stopword === null) {",
" $this->notFound('Stopword nicht gefunden');",
"+",
"+ return;",
" }",
" ",
" $this->repo->delete((int) $id);",
" ",
"- $_SESSION['success'] = \"Stopword '{$stopword['word']}' wurde gelöscht.\";",
"- $this->redirect('\/stopwords');",
"+ $_SESSION['success'] = \"Stopword '{$stopword['word']}' wurde geloescht.\";",
"+ $this->redirect('\/semantic-explorer\/stopwords');",
" }",
" ",
" public function toggle(string $id): void"
]
},
{
"oldStart": 142,
"oldLines": 12,
"newStart": 149,
"newLines": 14,
"lines": [
" $stopword = $this->repo->find((int) $id);",
" if ($stopword === null) {",
" $this->notFound('Stopword nicht gefunden');",
"+",
"+ return;",
" }",
" ",
" $this->repo->toggleActive((int) $id);",
" ",
" $newState = $stopword['is_active'] ? 'deaktiviert' : 'aktiviert';",
" $_SESSION['success'] = \"Stopword '{$stopword['word']}' wurde {$newState}.\";",
"- $this->redirect('\/stopwords');",
"+ $this->redirect('\/semantic-explorer\/stopwords');",
" }",
" }"
]
}
],
"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('stopwords.index', [\n 'title' => 'Stopwords verwalten',\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 stopwordsNew(): void\n {\n $this->view('stopwords.form', [\n 'title' => 'Neues Stopword',\n 'stopword' => null,\n 'isEdit' => false,\n ]);\n }\n\n public function store(): void\n {\n $this->requireCsrf();\n\n $word = trim($this->getString('word'));\n if ($word === '') {\n $_SESSION['error'] = 'Wort darf nicht leer sein.';\n $this->redirect('\/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 $_SESSION['success'] = \"Stopword '{$word}' wurde erstellt.\";\n $this->redirect('\/stopwords\/' . $id);\n } catch (\\PDOException $e) {\n if (str_contains($e->getMessage(), 'Duplicate')) {\n $_SESSION['error'] = \"Stopword '{$word}' existiert bereits.\";\n } else {\n $_SESSION['error'] = 'Fehler beim Speichern: ' . $e->getMessage();\n }\n $this->redirect('\/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('stopwords.form', [\n 'title' => 'Stopword: ' . $stopword['word'],\n 'stopword' => $stopword,\n 'isEdit' => true,\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 $_SESSION['error'] = 'Wort darf nicht leer sein.';\n $this->redirect('\/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 $_SESSION['success'] = 'Stopword wurde aktualisiert.';\n $this->redirect('\/stopwords\/' . $id);\n } catch (\\PDOException $e) {\n if (str_contains($e->getMessage(), 'Duplicate')) {\n $_SESSION['error'] = \"Stopword '{$word}' existiert bereits.\";\n } else {\n $_SESSION['error'] = 'Fehler beim Speichern: ' . $e->getMessage();\n }\n $this->redirect('\/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 gelöscht.\";\n $this->redirect('\/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('\/stopwords');\n }\n}\n"
}
}