ConfigController.php
- Pfad:
src/Controller/ConfigController.php - Namespace: Controller
- Zeilen: 202 | Größe: 6,354 Bytes
- Geändert: 2025-12-30 20:32:34 | Gescannt: 2025-12-31 10:22:15
Code Hygiene Score: 100
- Dependencies: 100 (25%)
- LOC: 100 (20%)
- Methods: 100 (20%)
- Secrets: 100 (15%)
- Classes: 100 (10%)
- Magic Numbers: 100 (10%)
Keine Issues gefunden.
Dependencies 6
- extends Framework\Controller
- constructor UseCases\Config\ManageConfigUseCase
- constructor Domain\Repository\PromptsRepositoryInterface
- use Domain\Repository\PromptsRepositoryInterface
- use Framework\Controller
- use UseCases\Config\ManageConfigUseCase
Klassen 1
-
ConfigControllerclass Zeile 13
Funktionen 8
-
__construct()public Zeile 29 -
index()public Zeile 35 -
configNew()public Zeile 51 -
store()public Zeile 64 -
show()public Zeile 102 -
edit()public Zeile 118 -
update()public Zeile 136 -
delete()public Zeile 175
Versionen 22
-
v22
2025-12-30 20:32 | claude-code-hook | modified
Claude Code Pre-Hook Backup vor Edit-Operation -
v21
2025-12-30 20:32 | claude-code-hook | modified
Claude Code Pre-Hook Backup vor Edit-Operation -
v20
2025-12-30 20:32 | claude-code-hook | modified
Claude Code Pre-Hook Backup vor Edit-Operation -
v19
2025-12-30 20:31 | claude-code-hook | modified
Claude Code Pre-Hook Backup vor Edit-Operation -
v18
2025-12-30 20:31 | claude-code-hook | modified
Claude Code Pre-Hook Backup vor Edit-Operation -
v17
2025-12-30 20:28 | claude-code-hook | modified
Claude Code Pre-Hook Backup vor Edit-Operation -
v16
2025-12-27 12:53 | claude-code-hook | modified
Claude Code Pre-Hook Backup vor Edit-Operation -
v15
2025-12-27 12:53 | claude-code-hook | modified
Claude Code Pre-Hook Backup vor Edit-Operation -
v14
2025-12-27 12:52 | claude-code-hook | modified
Claude Code Pre-Hook Backup vor Edit-Operation -
v13
2025-12-23 08:50 | claude-code-hook | modified
Claude Code Pre-Hook Backup vor Edit-Operation -
v12
2025-12-23 07:52 | claude-code-hook | modified
Claude Code Pre-Hook Backup vor Edit-Operation -
v11
2025-12-22 10:31 | claude-code-hook | modified
Claude Code Pre-Hook Backup vor Edit-Operation -
v10
2025-12-22 10:31 | claude-code-hook | modified
Claude Code Pre-Hook Backup vor Edit-Operation -
v9
2025-12-22 10:31 | claude-code-hook | modified
Claude Code Pre-Hook Backup vor Edit-Operation -
v8
2025-12-22 10:26 | claude-code-hook | modified
Claude Code Pre-Hook Backup vor Write-Operation -
v7
2025-12-22 10:18 | claude-code-hook | modified
Claude Code Pre-Hook Backup vor Edit-Operation -
v6
2025-12-22 08:05 | claude-code-hook | modified
Claude Code Pre-Hook Backup vor Edit-Operation -
v5
2025-12-22 01:45 | claude-code-hook | modified
Claude Code Pre-Hook Backup vor Edit-Operation -
v4
2025-12-22 01:45 | claude-code-hook | modified
Claude Code Pre-Hook Backup vor Edit-Operation -
v3
2025-12-22 01:45 | claude-code-hook | modified
Claude Code Pre-Hook Backup vor Edit-Operation -
v2
2025-12-22 01:45 | claude-code-hook | modified
Claude Code Pre-Hook Backup vor Edit-Operation -
v1
2025-12-21 02:30 | claude-code-hook | modified
Claude Code Pre-Hook Backup vor Edit-Operation
Code
<?php
declare(strict_types=1);
namespace Controller;
// @responsibility: HTTP-Endpunkte für Content-Konfiguration (Profile, Strukturen, Contracts, Critics)
use Domain\Repository\PromptsRepositoryInterface;
use Framework\Controller;
use UseCases\Config\ManageConfigUseCase;
class ConfigController extends Controller
{
private ManageConfigUseCase $configUseCase;
private PromptsRepositoryInterface $promptsRepo;
private const TYPES = ['author_profile', 'structure', 'organization', 'contract', 'rule', 'system_prompt', 'critic'];
private const TYPE_LABELS = [
'author_profile' => 'Autorenprofil',
'structure' => 'Struktur',
'organization' => 'Organisation',
'contract' => 'Contract',
'rule' => 'Regel',
'system_prompt' => 'System-Prompt',
'critic' => 'Kritiker',
];
public function __construct(ManageConfigUseCase $configUseCase, PromptsRepositoryInterface $promptsRepo)
{
$this->configUseCase = $configUseCase;
$this->promptsRepo = $promptsRepo;
}
public function index(): void
{
$typeFilter = $this->getString('type');
$statusFilter = $this->getString('status');
$this->view('config.index', [
'title' => 'Content-Konfiguration',
'configs' => array_map(fn ($dto) => $dto->toArray(), $this->configUseCase->getAll($typeFilter, $statusFilter)),
'stats' => $this->configUseCase->getStatistics(),
'types' => self::TYPES,
'typeLabels' => self::TYPE_LABELS,
'currentType' => $typeFilter,
'currentStatus' => $statusFilter,
]);
}
public function configNew(): void
{
$this->view('config.form', [
'title' => 'Neue Konfiguration',
'config' => null,
'types' => self::TYPES,
'typeLabels' => self::TYPE_LABELS,
'parents' => $this->configUseCase->getParentOptions(),
'prompts' => $this->promptsRepo->findActivePrompts(),
'isEdit' => false,
]);
}
public function store(): void
{
$this->requireCsrf();
$isHtmx = $this->isHtmxRequest();
$result = $this->configUseCase->create(
type: $_POST['type'] ?? '',
name: $_POST['name'] ?? '',
slug: $_POST['slug'] ?? '',
description: $_POST['description'] ?? null,
content: $_POST['content'] ?? '{}',
version: $_POST['version'] ?? '1.0',
status: $_POST['status'] ?? 'draft',
parentId: !empty($_POST['parent_id']) ? (int) $_POST['parent_id'] : null,
promptId: !empty($_POST['prompt_id']) ? (int) $_POST['prompt_id'] : null,
sortOrder: (int) ($_POST['sort_order'] ?? 0)
);
if (!$result->success) {
if ($isHtmx) {
$this->htmxError($result->message);
return;
}
$_SESSION['error'] = $result->message;
$this->redirect('/config/new');
}
if ($isHtmx) {
$this->htmxRedirect('/config/' . $result->id);
return;
}
$_SESSION['success'] = $result->message;
$this->redirect('/config/' . $result->id);
}
public function show(string $id): void
{
$config = $this->configUseCase->getById((int) $id);
if ($config === null) {
$this->notFound('Konfiguration nicht gefunden');
}
$this->view('config.show', [
'title' => $config->name,
'config' => $config->toArray(),
'children' => $this->configUseCase->getChildren((int) $id),
'history' => $this->configUseCase->getHistory((int) $id),
'typeLabels' => self::TYPE_LABELS,
]);
}
public function edit(string $id): void
{
$config = $this->configUseCase->getById((int) $id);
if ($config === null) {
$this->notFound('Konfiguration nicht gefunden');
}
$this->view('config.form', [
'title' => 'Bearbeiten: ' . $config->name,
'config' => $config->toArray(),
'types' => self::TYPES,
'typeLabels' => self::TYPE_LABELS,
'parents' => $this->configUseCase->getParentOptions((int) $id),
'prompts' => $this->promptsRepo->findActivePrompts(),
'isEdit' => true,
]);
}
public function update(string $id): void
{
$this->requireCsrf();
$isHtmx = $this->isHtmxRequest();
$result = $this->configUseCase->update(
id: (int) $id,
name: $_POST['name'] ?? '',
slug: $_POST['slug'] ?? '',
description: $_POST['description'] ?? null,
content: $_POST['content'] ?? '{}',
newVersion: $_POST['new_version'] ?? '',
changeDescription: $_POST['change_description'] ?? '',
status: $_POST['status'] ?? 'draft',
parentId: !empty($_POST['parent_id']) ? (int) $_POST['parent_id'] : null,
promptId: !empty($_POST['prompt_id']) ? (int) $_POST['prompt_id'] : null,
sortOrder: (int) ($_POST['sort_order'] ?? 0)
);
if (!$result->success) {
if ($isHtmx) {
$this->htmxError($result->message);
return;
}
$_SESSION['error'] = $result->message;
$this->redirect('/config/' . $id . '/edit');
}
if ($isHtmx) {
$this->htmxRedirect('/config/' . $id);
return;
}
$_SESSION['success'] = $result->message;
$this->redirect('/config/' . $id);
}
public function delete(string $id): void
{
$this->requireCsrf();
$isHtmx = $this->isHtmxRequest();
$result = $this->configUseCase->delete((int) $id);
if (!$result->success) {
if ($isHtmx) {
$this->htmxError($result->message);
return;
}
$_SESSION['error'] = $result->message;
$this->redirect('/config/' . $id);
}
if ($isHtmx) {
$this->htmxRedirect('/config');
return;
}
$_SESSION['success'] = $result->message;
$this->redirect('/config');
}
}