'Autorenprofil', 'structure' => 'Struktur', 'organization' => 'Organisation', 'contract' => 'Contract', 'rule' => 'Regel', 'system_prompt' => 'System-Prompt', ]; public function __construct(?ManageConfigUseCase $configUseCase = null) { $this->configUseCase = $configUseCase ?? new ManageConfigUseCase(); } public function index(): void { $typeFilter = $this->getString('type'); $statusFilter = $this->getString('status'); $this->view('config.index', [ 'title' => 'Content-Konfiguration', 'configs' => array_map(fn ($dto) => (array) $dto, $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(), 'isEdit' => false, ]); } public function store(): void { $this->requireCsrf(); $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 ); if (!$result->success) { $_SESSION['error'] = $result->message; header('Location: /config/new'); exit; } $_SESSION['success'] = $result->message; header('Location: /config/' . $result->id); exit; } 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' => (array) $config, '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' => (array) $config, 'types' => self::TYPES, 'typeLabels' => self::TYPE_LABELS, 'parents' => $this->configUseCase->getParentOptions((int) $id), 'isEdit' => true, ]); } public function update(string $id): void { $this->requireCsrf(); $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 ); if (!$result->success) { $_SESSION['error'] = $result->message; header('Location: /config/' . $id . '/edit'); exit; } $_SESSION['success'] = $result->message; header('Location: /config/' . $id); exit; } public function delete(string $id): void { $this->requireCsrf(); $result = $this->configUseCase->delete((int) $id); if (!$result->success) { $_SESSION['error'] = $result->message; header('Location: /config/' . $id); exit; } $_SESSION['success'] = $result->message; header('Location: /config'); exit; } }