{
"event": "PreToolUse",
"tool_name": "Read",
"tool_input": {
"file_path": "\/var\/www\/dev.campus.systemische-tools.de\/src\/View\/semantic-explorer\/stopwords\/edit.php"
}
}
{
"tool_response": {
"type": "text",
"file": {
"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\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\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 $_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 $_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\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",
"numLines": 151,
"startLine": 1,
"totalLines": 151
}
}
}