{
"event": "PostToolUse",
"tool_name": "Read",
"tool_response": {
"type": "text",
"file": {
"filePath": "\/var\/www\/dev.campus.systemische-tools.de\/src\/Controller\/TaxonomyController.php",
"content": " }\n\n \/**\n * POST \/semantic-explorer\/taxonomie\n *\/\n public function store(): void\n {\n $input = $this->getJsonInput();\n\n $name = trim($input['name'] ?? '');\n $parentId = isset($input['parent_id']) && $input['parent_id'] !== '' ? (int) $input['parent_id'] : null;\n\n if ($name === '') {\n $this->json($this->apiFormatter->validationError('Name ist erforderlich', ['name' => 'Pflichtfeld']), 400);\n\n return;\n }\n\n try {\n $id = $this->repository->create($name, $parentId);\n $this->json($this->apiFormatter->created($id, 'Taxonomie-Begriff erstellt'));\n } catch (\\Exception $e) {\n $this->json($this->apiFormatter->error($e->getMessage(), 'SERVER_ERROR'), 500);\n }\n }\n\n \/**\n * GET \/semantic-explorer\/taxonomie\/{id}\/edit\n *\/\n public function edit(int $id): void\n {\n $term = $this->repository->find($id);\n\n if ($term === null) {\n $this->notFound('Begriff nicht gefunden');\n }\n\n $this->view('semantic-explorer.taxonomie.edit', [\n 'title' => 'Begriff bearbeiten',\n 'term' => $term,\n 'terms' => $this->repository->findForSelect(),\n ]);\n }\n\n \/**\n * POST \/semantic-explorer\/taxonomie\/{id}\n *\/\n public function update(int $id): void\n {\n $input = $this->getJsonInput();\n\n $name = trim($input['name'] ?? '');\n $parentId = isset($input['parent_id']) && $input['parent_id'] !== '' ? (int) $input['parent_id'] : null;\n\n if ($name === '') {\n $this->json($this->apiFormatter->validationError('Name ist erforderlich', ['name' => 'Pflichtfeld']), 400);\n\n return;\n }\n\n try {\n $this->repository->update($id, $name, $parentId);\n $this->json($this->apiFormatter->ok('Taxonomie-Begriff aktualisiert'));\n } catch (\\Exception $e) {\n $this->json($this->apiFormatter->error($e->getMessage(), 'SERVER_ERROR'), 500);\n }\n }\n\n \/**\n * POST \/semantic-explorer\/taxonomie\/{id}\/delete\n *\/\n public function destroy(int $id): void\n {\n try {\n $success = $this->repository->delete($id);\n if ($success) {\n $this->json($this->apiFormatter->ok('Taxonomie-Begriff gelöscht'));\n } else {\n $this->json($this->apiFormatter->error('Begriff hat noch Unterbegriffe', 'HAS_CHILDREN'), 400);\n }\n } catch (\\Exception $e) {\n $this->json($this->apiFormatter->error($e->getMessage(), 'SERVER_ERROR'), 500);\n }\n }\n\n \/**\n * Baut Baum aus flacher Liste\n *\/\n private function buildTaxonomyTree(array $items, ?int $parentId = null): array\n {\n $tree = [];\n foreach ($items as $item) {\n if ($item['parent_id'] == $parentId) {\n $item['children'] = $this->buildTaxonomyTree($items, $item['id']);\n $tree[] = $item;\n }\n }\n\n return $tree;\n }",
"numLines": 100,
"startLine": 53,
"totalLines": 154
}
}
}