{
"event": "PostToolUse",
"tool_name": "Read",
"tool_response": {
"type": "text",
"file": {
"filePath": "\/var\/www\/dev.campus.systemische-tools.de\/src\/Controller\/ContentController.php",
"content": "<?php\n\ndeclare(strict_types=1);\n\nnamespace Controller;\n\n\/\/ @responsibility: HTTP-Endpunkte für Content Studio (Aufträge, Generierung, Kritik)\n\nuse Application\\ContentCollectionService;\nuse Domain\\Repository\\ContentRepositoryInterface;\nuse Framework\\Controller;\nuse Infrastructure\\AI\\ModelRegistry;\nuse UseCases\\Command\\CreateContentOrderCommand;\nuse UseCases\\Command\\GenerateContentCommand;\nuse UseCases\\Content\\GenerateContentUseCase;\n\nclass ContentController extends Controller\n{\n public function __construct(\n private ContentRepositoryInterface $repository,\n private ContentCollectionService $collectionService,\n private GenerateContentUseCase $generateUseCase,\n private ModelRegistry $modelRegistry\n ) {\n }\n\n \/**\n * GET \/content - List all content orders\n *\/\n public function index(): void\n {\n $status = $this->getString('status');\n\n $this->view('content.index', [\n 'title' => 'Content Studio',\n 'orders' => $this->repository->findAllOrders($status !== '' ? ['status' => $status] : []),\n 'stats' => $this->repository->getStatistics(),\n 'currentStatus' => $status,\n ]);\n }\n\n \/**\n * GET \/content\/new - Show create form\n *\/\n public function contentNew(): void\n {\n $lastSettings = $this->repository->getLastOrderSettings();\n\n $this->view('content.new', [\n 'title' => 'Neuer Content-Auftrag',\n 'profiles' => $this->repository->findAllProfiles(),\n 'contracts' => $this->repository->findAllContracts(),\n 'structures' => $this->repository->findAllStructures(),\n 'systemPrompts' => $this->repository->findAllSystemPrompts(),\n 'critics' => $this->repository->findAllCritics(),\n 'models' => $this->modelRegistry->getChatModels(),\n 'collections' => $this->collectionService->getAvailable(),\n 'defaultModel' => $lastSettings['model'],\n 'defaultCollections' => $lastSettings['collections'],\n 'defaultContextLimit' => $lastSettings['context_limit'],\n 'defaultProfileId' => $lastSettings['author_profile_id'],\n 'defaultContractId' => $lastSettings['contract_id'],\n 'defaultStructureId' => $lastSettings['structure_id'],\n 'defaultTemperature' => $lastSettings['temperature'],\n 'defaultMaxTokens' => $lastSettings['max_tokens'],\n 'defaultSystemPromptId' => $lastSettings['system_prompt_id'],\n 'defaultSelectedCritics' => $lastSettings['selected_critics'],\n 'defaultQualityCheck' => $lastSettings['quality_check'],\n ]);\n }\n\n \/**\n * POST \/content - Store new order\n *\/\n public function store(): void\n {\n $this->requireCsrf();\n\n $isHtmx = $this->isHtmxRequest();\n $command = CreateContentOrderCommand::fromRequest($_POST);\n $errors = $command->validate();\n\n if ($errors !== []) {\n if ($isHtmx) {\n $this->htmxError(implode(' ', $errors));\n\n return;\n }\n $_SESSION['error'] = implode(' ', $errors);\n $this->redirect('\/content\/new');\n }\n\n \/\/ Validate collections\n $result = $this->collectionService->validateWithCompatibility($command->collections);\n if (!$result['valid']) {\n if ($isHtmx) {\n $this->htmxError('Collection-Fehler: ' . $result['error']);\n\n return;\n }\n $_SESSION['error'] = 'Collection-Fehler: ' . $result['error'];\n $this->redirect('\/content\/new');\n }\n\n $orderId = $this->repository->createOrder([\n 'title' => $command->title,\n 'briefing' => $command->briefing,\n 'author_profile_id' => $command->authorProfileId,\n 'contract_id' => $command->contractId ?? $this->getFirstContractId(),\n 'structure_id' => $command->structureId,\n 'model' => $this->modelRegistry->isValid($command->model) ? $command->model : $this->modelRegistry->getDefaultChatModel(),\n 'collections' => json_encode($result['collections']),\n 'context_limit' => $command->contextLimit,\n 'temperature' => $command->temperature,\n 'max_tokens' => $command->maxTokens,\n 'system_prompt_id' => $command->systemPromptId,\n 'selected_critics' => $command->selectedCritics,\n 'quality_check' => $command->qualityCheck,\n ]);\n\n if ($command->shouldGenerate()) {\n \/\/ Start async generation (non-blocking)\n $this->repository->updateGenerationStatus($orderId, 'generating');\n $this->generateUseCase->generateAsync(\n $orderId,\n $this->modelRegistry->isValid($command->model) ? $command->model : $this->modelRegistry->getDefaultChatModel(),\n $result['collections'][0] ?? 'documents',\n $command->contextLimit\n );\n }\n\n if ($isHtmx) {\n $this->htmxRedirect('\/content\/' . $orderId);\n\n return;\n }\n\n $this->redirect('\/content\/' . $orderId);\n }\n\n \/**\n * GET \/content\/{id} - Show order details\n *\/\n public function show(int $id): void\n {\n $order = $this->repository->findOrder($id);\n if ($order === null) {\n $this->notFound('Auftrag nicht gefunden');\n }\n",
"numLines": 150,
"startLine": 1,
"totalLines": 435
}
}
}