{
"event": "PostToolUse",
"tool_name": "Read",
"tool_response": {
"type": "text",
"file": {
"filePath": "\/var\/www\/dev.campus.systemische-tools.de\/src\/Controller\/Api\/ContentController.php",
"content": "<?php\n\ndeclare(strict_types=1);\n\nnamespace Controller\\Api;\n\n\/\/ @responsibility: REST-API für Content-Aufträge\n\nuse Domain\\Repository\\ContentRepositoryInterface;\nuse Framework\\Controller;\n\nclass ContentController extends Controller\n{\n private ContentRepositoryInterface $repository;\n\n public function __construct(ContentRepositoryInterface $repository)\n {\n $this->repository = $repository;\n }\n\n public function update(int $id): void\n {\n $this->requireCsrf();\n\n try {\n $order = $this->repository->findOrder($id);\n\n if ($order === null) {\n $this->sendError('Auftrag nicht gefunden', 404);\n\n return;\n }\n\n \/\/ Accept both JSON and form data\n $input = $this->getJsonInput();\n if (empty($input)) {\n $input = $_POST;\n }\n\n if (!isset($input['title']) || trim((string) $input['title']) === '') {\n $this->sendError('Titel ist erforderlich', 400);\n\n return;\n }\n\n if (!isset($input['briefing']) || trim((string) $input['briefing']) === '') {\n $this->sendError('Briefing ist erforderlich', 400);\n\n return;\n }\n\n $this->repository->updateOrder($id, [\n 'title' => $input['title'],\n 'briefing' => $input['briefing'],\n 'author_profile_id' => !empty($input['author_profile_id']) ? (int) $input['author_profile_id'] : null,\n 'contract_id' => !empty($input['contract_id']) ? (int) $input['contract_id'] : null,\n 'structure_id' => !empty($input['structure_id']) ? (int) $input['structure_id'] : null,\n ]);\n\n \/\/ HTMX: Redirect to detail page\n if ($this->isHtmxRequest()) {\n $this->htmxRedirect('\/content\/' . $id);\n\n return;\n }\n\n \/\/ JSON fallback\n $updatedOrder = $this->repository->findOrder($id);\n $this->json([\n 'success' => true,\n 'data' => $updatedOrder,\n ]);\n } catch (\\Exception $e) {\n $this->sendError($e->getMessage());\n }\n }\n\n private function sendError(string $message, int $status = 500): void\n {\n if ($this->isHtmxRequest()) {\n $this->htmxError($message);\n\n return;\n }\n $this->json(['success' => false, 'error' => $message], $status);\n }\n}\n",
"numLines": 88,
"startLine": 1,
"totalLines": 88
}
}
}