Backup #1737
| ID | 1737 |
| Dateipfad | /var/www/dev.campus.systemische-tools.de/src/Controller/StopwordController.php |
| Version | 12 |
| Typ |
modified |
| Größe | 5.7 KB |
| Hash | ec9cbc97ed21261cb54b96fa12a1b3a393ad2f890961dbd95d96743d622145bc |
| Datum | 2025-12-27 12:40:18 |
| Geändert von | claude-code-hook |
| Grund | Claude Code Pre-Hook Backup vor Edit-Operation |
| Datei existiert |
Ja
|
Dateiinhalt
<?php
declare(strict_types=1);
namespace Controller;
// @responsibility: HTTP-Endpunkte für Stopword-Verwaltung (Entity-Extraction Filter)
use Domain\Repository\StopwordRepositoryInterface;
use Framework\Controller;
class StopwordController extends Controller
{
private StopwordRepositoryInterface $repo;
public function __construct(StopwordRepositoryInterface $repo)
{
$this->repo = $repo;
}
public function index(): void
{
$category = $this->getString('category');
$showAll = $this->getString('all') === '1';
$this->view('semantic-explorer.stopwords.index', [
'title' => 'Stopwords - Semantic Explorer',
'stopwords' => $this->repo->findAll(!$showAll, $category ?: null),
'stats' => $this->repo->getStats(),
'currentCategory' => $category,
'showAll' => $showAll,
]);
}
public function create(): void
{
$this->view('semantic-explorer.stopwords.new', [
'title' => 'Neues Stopword - Semantic Explorer',
]);
}
public function store(): void
{
$this->requireCsrf();
$isHtmx = $this->isHtmxRequest();
$word = trim($this->getString('word'));
if ($word === '') {
if ($isHtmx) {
$this->htmxError('Wort darf nicht leer sein.');
return;
}
$_SESSION['error'] = 'Wort darf nicht leer sein.';
$this->redirect('/semantic-explorer/stopwords/new');
}
try {
$id = $this->repo->create([
'word' => $word,
'category' => $this->getString('category') ?: 'generic',
'reason' => $this->getString('reason') ?: null,
'is_active' => isset($_POST['is_active']) ? 1 : 0,
]);
if ($isHtmx) {
$this->htmxRedirect('/semantic-explorer/stopwords/' . $id);
return;
}
$_SESSION['success'] = "Stopword '{$word}' wurde erstellt.";
$this->redirect('/semantic-explorer/stopwords/' . $id);
} catch (\PDOException $e) {
$errorMsg = str_contains($e->getMessage(), 'Duplicate')
? "Stopword '{$word}' existiert bereits."
: 'Fehler beim Speichern: ' . $e->getMessage();
if ($isHtmx) {
$this->htmxError($errorMsg);
return;
}
$_SESSION['error'] = $errorMsg;
$this->redirect('/semantic-explorer/stopwords/new');
}
}
public function show(string $id): void
{
$stopword = $this->repo->find((int) $id);
if ($stopword === null) {
$this->notFound('Stopword nicht gefunden');
}
$this->view('semantic-explorer.stopwords.edit', [
'title' => 'Stopword: ' . $stopword['word'],
'stopword' => $stopword,
]);
}
public function update(string $id): void
{
$this->requireCsrf();
$stopword = $this->repo->find((int) $id);
if ($stopword === null) {
$this->notFound('Stopword nicht gefunden');
}
$word = trim($this->getString('word'));
if ($word === '') {
if ($this->isHtmxRequest()) {
$this->htmxError('Wort darf nicht leer sein.');
return;
}
$_SESSION['error'] = 'Wort darf nicht leer sein.';
$this->redirect('/semantic-explorer/stopwords/' . $id);
}
try {
$this->repo->update((int) $id, [
'word' => $word,
'category' => $this->getString('category') ?: 'generic',
'reason' => $this->getString('reason') ?: null,
'is_active' => isset($_POST['is_active']) ? 1 : 0,
]);
if ($this->isHtmxRequest()) {
$this->htmxRedirect('/semantic-explorer/stopwords/' . $id);
return;
}
$_SESSION['success'] = 'Stopword wurde aktualisiert.';
$this->redirect('/semantic-explorer/stopwords/' . $id);
} catch (\PDOException $e) {
$errorMsg = str_contains($e->getMessage(), 'Duplicate')
? "Stopword '{$word}' existiert bereits."
: 'Fehler beim Speichern: ' . $e->getMessage();
if ($this->isHtmxRequest()) {
$this->htmxError($errorMsg);
return;
}
$_SESSION['error'] = $errorMsg;
$this->redirect('/semantic-explorer/stopwords/' . $id);
}
}
public function delete(string $id): void
{
$this->requireCsrf();
$stopword = $this->repo->find((int) $id);
if ($stopword === null) {
$this->notFound('Stopword nicht gefunden');
}
$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');
}
public function toggle(string $id): void
{
$this->requireCsrf();
$stopword = $this->repo->find((int) $id);
if ($stopword === null) {
$this->notFound('Stopword nicht gefunden');
}
$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');
}
}
Vollständig herunterladen
Aktionen
Andere Versionen dieser Datei
| ID |
Version |
Typ |
Größe |
Datum |
| 1739 |
14 |
modified |
5.8 KB |
2025-12-27 12:41 |
| 1738 |
13 |
modified |
5.7 KB |
2025-12-27 12:41 |
| 1737 |
12 |
modified |
5.7 KB |
2025-12-27 12:40 |
| 1736 |
11 |
modified |
5.7 KB |
2025-12-27 12:39 |
| 1733 |
10 |
modified |
5.5 KB |
2025-12-27 12:37 |
| 1732 |
9 |
modified |
5.1 KB |
2025-12-27 12:37 |
| 1731 |
8 |
modified |
4.7 KB |
2025-12-27 12:37 |
| 1612 |
7 |
modified |
4.7 KB |
2025-12-27 00:28 |
| 1611 |
6 |
modified |
4.7 KB |
2025-12-27 00:28 |
| 1610 |
5 |
modified |
4.7 KB |
2025-12-27 00:28 |
| 1609 |
4 |
modified |
4.7 KB |
2025-12-27 00:28 |
| 1608 |
3 |
modified |
4.8 KB |
2025-12-27 00:28 |
| 1607 |
2 |
modified |
4.8 KB |
2025-12-27 00:28 |
| 1603 |
1 |
modified |
4.5 KB |
2025-12-27 00:25 |
← Zurück zur Übersicht