{
"event": "PreToolUse",
"tool_name": "Edit",
"tool_input": {
"file_path": "\/var\/www\/dev.campus.systemische-tools.de\/src\/Controller\/Api\/ContentController.php",
"old_string": "class ContentController extends Controller\n{\n private ContentRepository $repository;\n\n public function __construct()\n {\n $this->repository = new ContentRepository();\n }",
"new_string": "class ContentController extends Controller\n{\n private ContentRepository $repository;\n\n public function __construct(?ContentRepository $repository = null)\n {\n $this->repository = $repository ?? new ContentRepository();\n }"
}
}
{
"tool_response": {
"filePath": "\/var\/www\/dev.campus.systemische-tools.de\/src\/Controller\/Api\/ContentController.php",
"oldString": "class ContentController extends Controller\n{\n private ContentRepository $repository;\n\n public function __construct()\n {\n $this->repository = new ContentRepository();\n }",
"newString": "class ContentController extends Controller\n{\n private ContentRepository $repository;\n\n public function __construct(?ContentRepository $repository = null)\n {\n $this->repository = $repository ?? new ContentRepository();\n }",
"originalFile": "<?php\n\nnamespace Controller\\Api;\n\nuse Framework\\Controller;\nuse Infrastructure\\Persistence\\ContentRepository;\n\nclass ContentController extends Controller\n{\n private ContentRepository $repository;\n\n public function __construct()\n {\n $this->repository = new ContentRepository();\n }\n\n public function update(int $id): void\n {\n try {\n $order = $this->repository->findOrder($id);\n\n if ($order === null) {\n $this->json(['success' => false, 'error' => 'Auftrag nicht gefunden'], 404);\n\n return;\n }\n\n $input = $this->getJsonInput();\n\n if (!isset($input['title']) || trim((string) $input['title']) === '') {\n $this->json(['success' => false, 'error' => 'Titel ist erforderlich'], 400);\n\n return;\n }\n\n if (!isset($input['briefing']) || trim((string) $input['briefing']) === '') {\n $this->json(['success' => false, 'error' => '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' => $input['author_profile_id'] ?? null,\n 'contract_id' => $input['contract_id'] ?? null,\n 'structure_id' => $input['structure_id'] ?? null,\n ]);\n\n $updatedOrder = $this->repository->findOrder($id);\n\n $this->json([\n 'success' => true,\n 'data' => $updatedOrder,\n ]);\n } catch (\\Exception $e) {\n $this->jsonError($e->getMessage());\n }\n }\n}\n",
"structuredPatch": [
{
"oldStart": 9,
"oldLines": 9,
"newStart": 9,
"newLines": 9,
"lines": [
" {",
" private ContentRepository $repository;",
" ",
"- public function __construct()",
"+ public function __construct(?ContentRepository $repository = null)",
" {",
"- $this->repository = new ContentRepository();",
"+ $this->repository = $repository ?? new ContentRepository();",
" }",
" ",
" public function update(int $id): void"
]
}
],
"userModified": false,
"replaceAll": false
}
}