{
"event": "PreToolUse",
"tool_name": "Read",
"tool_input": {
"file_path": "\/var\/www\/dev.campus.systemische-tools.de\/src\/Controller\/ContentController.php",
"offset": 315,
"limit": 80
}
}
{
"tool_response": {
"type": "text",
"file": {
"filePath": "\/var\/www\/dev.campus.systemische-tools.de\/src\/Controller\/ContentController.php",
"content": " public function decline(int $id): void\n {\n $this->requireCsrf();\n\n $this->repository->updateOrderStatus($id, 'draft');\n echo '<div class=\"alert warning\">Content abgelehnt. Zurück zu Entwurf.<\/div>';\n echo '<script>setTimeout(() => window.location.reload(), 1000);<\/script>';\n }\n\n \/**\n * Allowed Python commands (whitelist).\n *\/\n private const ALLOWED_COMMANDS = ['generate', 'critique', 'revise'];\n\n \/**\n * Call Python script\n *\/\n private function callPython(string $command, int $entityId, array $args = []): array\n {\n \/\/ Validate command against whitelist\n if (!in_array($command, self::ALLOWED_COMMANDS, true)) {\n return ['error' => 'Ungültiger Command: ' . $command];\n }\n\n $scriptPath = $this->pipelinePath . '\/web_generate.py';\n\n \/\/ Build command array for proc_open (safer than shell_exec)\n $cmdArray = [\n $this->pythonPath,\n $scriptPath,\n $command,\n (string) $entityId,\n ...$args,\n ];\n\n $descriptors = [\n 0 => ['pipe', 'r'],\n 1 => ['pipe', 'w'],\n 2 => ['pipe', 'w'],\n ];\n\n $process = proc_open($cmdArray, $descriptors, $pipes); \/\/ nosemgrep: exec-use\n\n if (!is_resource($process)) {\n return ['error' => 'Script konnte nicht gestartet werden'];\n }\n\n fclose($pipes[0]);\n $stdout = stream_get_contents($pipes[1]);\n $stderr = stream_get_contents($pipes[2]);\n fclose($pipes[1]);\n fclose($pipes[2]);\n $exitCode = proc_close($process);\n\n $output = $stdout . $stderr;\n\n if ($exitCode !== 0 && $output === '') {\n return ['error' => 'Script fehlgeschlagen (Exit: ' . $exitCode . ')'];\n }\n\n if (preg_match('\/\\{[\\s\\S]*\\}\/', $output, $matches)) {\n $result = json_decode($matches[0], true);\n if (json_last_error() === JSON_ERROR_NONE) {\n return $result;\n }\n }\n\n return ['error' => 'Ungültige Antwort: ' . substr($output, 0, 500)];\n }\n\n \/**\n * Render version partial\n *\/\n private function renderVersionPartial(array $result): void\n {\n $this->view('content.partials.version', [\n 'content' => $result['content'] ?? '',\n 'sources' => $result['sources'] ?? [],\n 'versionNumber' => $result['version_number'] ?? '?',\n ]);",
"numLines": 80,
"startLine": 315,
"totalLines": 461
}
}
}