{
"event": "PreToolUse",
"tool_name": "Edit",
"tool_input": {
"file_path": "\/var\/www\/dev.campus.systemische-tools.de\/src\/Controller\/Api\/ContentController.php",
"old_string": " \/\/ 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 }",
"new_string": " \/\/ JSON fallback\n $updatedOrder = $this->repository->findOrder($id);\n $this->json([\n 'success' => true,\n 'data' => $updatedOrder,\n ]);\n } catch (\\Exception $e) {\n error_log(sprintf('[API.Content.update] %s: %s', get_class($e), $e->getMessage()));\n $this->sendError($e->getMessage());\n }\n }"
}
}
{
"tool_response": {
"filePath": "\/var\/www\/dev.campus.systemische-tools.de\/src\/Controller\/Api\/ContentController.php",
"oldString": " \/\/ 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 }",
"newString": " \/\/ JSON fallback\n $updatedOrder = $this->repository->findOrder($id);\n $this->json([\n 'success' => true,\n 'data' => $updatedOrder,\n ]);\n } catch (\\Exception $e) {\n error_log(sprintf('[API.Content.update] %s: %s', get_class($e), $e->getMessage()));\n $this->sendError($e->getMessage());\n }\n }",
"originalFile": "<?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",
"structuredPatch": [
{
"oldStart": 71,
"oldLines": 6,
"newStart": 71,
"newLines": 7,
"lines": [
" 'data' => $updatedOrder,",
" ]);",
" } catch (\\Exception $e) {",
"+ error_log(sprintf('[API.Content.update] %s: %s', get_class($e), $e->getMessage()));",
" $this->sendError($e->getMessage());",
" }",
" }"
]
}
],
"userModified": false,
"replaceAll": false
}
}