{
"event": "PreToolUse",
"tool_name": "Write",
"tool_input": {
"file_path": "\/var\/www\/dev.campus.systemische-tools.de\/src\/Controller\/EntityController.php",
"content": "<?php\n\nnamespace Controller;\n\nuse Framework\\Controller;\nuse Infrastructure\\SemanticExplorerRepository;\n\n\/**\n * EntityController - CRUD for Semantic Explorer Entities\n *\n * Extracted from SemanticExplorerController for SRP compliance.\n *\/\nclass EntityController extends Controller\n{\n private SemanticExplorerRepository $repository;\n\n public function __construct()\n {\n $this->repository = new SemanticExplorerRepository();\n }\n\n \/**\n * GET \/semantic-explorer\/entitaeten\n * Liste aller Entitaeten\n *\/\n public function index(): void\n {\n $type = $_GET['type'] ?? '';\n $search = $_GET['search'] ?? '';\n\n $entities = $this->repository->getEntitiesFiltered($type, $search);\n $stats = $this->repository->getEntityStats();\n\n $this->view('semantic-explorer.entitaeten.index', [\n 'title' => 'Entitaeten',\n 'entities' => $entities,\n 'stats' => $stats,\n 'currentType' => $type,\n 'currentSearch' => $search,\n ]);\n }\n\n \/**\n * GET \/semantic-explorer\/entitaeten\/{id}\n * Entitaet-Details\n *\/\n public function show(int $id): void\n {\n $entity = $this->repository->getEntity($id);\n\n if ($entity === null) {\n $this->notFound('Entitaet nicht gefunden');\n }\n\n $synonyms = $this->repository->getEntitySynonyms($id);\n $outgoingRelations = $this->repository->getOutgoingRelations($id);\n $incomingRelations = $this->repository->getIncomingRelations($id);\n $chunks = $this->repository->getChunksForEntity($id);\n $classifications = $this->repository->getEntityClassifications($id);\n\n $this->view('semantic-explorer.entitaeten.show', [\n 'title' => $entity['name'],\n 'entity' => $entity,\n 'synonyms' => $synonyms,\n 'outgoingRelations' => $outgoingRelations,\n 'incomingRelations' => $incomingRelations,\n 'chunks' => $chunks,\n 'classifications' => $classifications,\n ]);\n }\n\n \/**\n * GET \/semantic-explorer\/entitaeten\/new\n *\/\n public function create(): void\n {\n $this->view('semantic-explorer.entitaeten.new', [\n 'title' => 'Neue Entitaet',\n 'types' => $this->repository->getEntityTypes(),\n ]);\n }\n\n \/**\n * POST \/semantic-explorer\/entitaeten\n *\/\n public function store(): void\n {\n $input = json_decode(file_get_contents('php:\/\/input'), true);\n\n $name = trim($input['name'] ?? '');\n $type = trim($input['type'] ?? '');\n $description = trim($input['description'] ?? '') ?: null;\n\n if ($name === '' || $type === '') {\n $this->json(['success' => false, 'error' => 'Name und Typ sind erforderlich'], 400);\n\n return;\n }\n\n try {\n $id = $this->repository->createEntity($name, $type, $description);\n $this->json(['success' => true, 'id' => $id]);\n } catch (\\Exception $e) {\n $this->json(['success' => false, 'error' => $e->getMessage()], 500);\n }\n }\n\n \/**\n * GET \/semantic-explorer\/entitaeten\/{id}\/edit\n *\/\n public function edit(int $id): void\n {\n $entity = $this->repository->getEntity($id);\n\n if ($entity === null) {\n $this->notFound('Entitaet nicht gefunden');\n }\n\n $this->view('semantic-explorer.entitaeten.edit', [\n 'title' => 'Entitaet bearbeiten',\n 'entity' => $entity,\n 'types' => $this->repository->getEntityTypes(),\n ]);\n }\n\n \/**\n * POST \/semantic-explorer\/entitaeten\/{id}\n *\/\n public function update(int $id): void\n {\n $input = json_decode(file_get_contents('php:\/\/input'), true);\n\n $name = trim($input['name'] ?? '');\n $type = trim($input['type'] ?? '');\n $description = trim($input['description'] ?? '') ?: null;\n\n if ($name === '' || $type === '') {\n $this->json(['success' => false, 'error' => 'Name und Typ sind erforderlich'], 400);\n\n return;\n }\n\n try {\n $this->repository->updateEntity($id, $name, $type, $description);\n $this->json(['success' => true]);\n } catch (\\Exception $e) {\n $this->json(['success' => false, 'error' => $e->getMessage()], 500);\n }\n }\n\n \/**\n * POST \/semantic-explorer\/entitaeten\/{id}\/delete\n *\/\n public function delete(int $id): void\n {\n try {\n $success = $this->repository->deleteEntity($id);\n if ($success) {\n $this->json(['success' => true]);\n } else {\n $this->json(['success' => false, 'error' => 'Entitaet hat noch Relationen'], 400);\n }\n } catch (\\Exception $e) {\n $this->json(['success' => false, 'error' => $e->getMessage()], 500);\n }\n }\n}\n"
}
}
{
"tool_response": {
"type": "create",
"filePath": "\/var\/www\/dev.campus.systemische-tools.de\/src\/Controller\/EntityController.php",
"content": "<?php\n\nnamespace Controller;\n\nuse Framework\\Controller;\nuse Infrastructure\\SemanticExplorerRepository;\n\n\/**\n * EntityController - CRUD for Semantic Explorer Entities\n *\n * Extracted from SemanticExplorerController for SRP compliance.\n *\/\nclass EntityController extends Controller\n{\n private SemanticExplorerRepository $repository;\n\n public function __construct()\n {\n $this->repository = new SemanticExplorerRepository();\n }\n\n \/**\n * GET \/semantic-explorer\/entitaeten\n * Liste aller Entitaeten\n *\/\n public function index(): void\n {\n $type = $_GET['type'] ?? '';\n $search = $_GET['search'] ?? '';\n\n $entities = $this->repository->getEntitiesFiltered($type, $search);\n $stats = $this->repository->getEntityStats();\n\n $this->view('semantic-explorer.entitaeten.index', [\n 'title' => 'Entitaeten',\n 'entities' => $entities,\n 'stats' => $stats,\n 'currentType' => $type,\n 'currentSearch' => $search,\n ]);\n }\n\n \/**\n * GET \/semantic-explorer\/entitaeten\/{id}\n * Entitaet-Details\n *\/\n public function show(int $id): void\n {\n $entity = $this->repository->getEntity($id);\n\n if ($entity === null) {\n $this->notFound('Entitaet nicht gefunden');\n }\n\n $synonyms = $this->repository->getEntitySynonyms($id);\n $outgoingRelations = $this->repository->getOutgoingRelations($id);\n $incomingRelations = $this->repository->getIncomingRelations($id);\n $chunks = $this->repository->getChunksForEntity($id);\n $classifications = $this->repository->getEntityClassifications($id);\n\n $this->view('semantic-explorer.entitaeten.show', [\n 'title' => $entity['name'],\n 'entity' => $entity,\n 'synonyms' => $synonyms,\n 'outgoingRelations' => $outgoingRelations,\n 'incomingRelations' => $incomingRelations,\n 'chunks' => $chunks,\n 'classifications' => $classifications,\n ]);\n }\n\n \/**\n * GET \/semantic-explorer\/entitaeten\/new\n *\/\n public function create(): void\n {\n $this->view('semantic-explorer.entitaeten.new', [\n 'title' => 'Neue Entitaet',\n 'types' => $this->repository->getEntityTypes(),\n ]);\n }\n\n \/**\n * POST \/semantic-explorer\/entitaeten\n *\/\n public function store(): void\n {\n $input = json_decode(file_get_contents('php:\/\/input'), true);\n\n $name = trim($input['name'] ?? '');\n $type = trim($input['type'] ?? '');\n $description = trim($input['description'] ?? '') ?: null;\n\n if ($name === '' || $type === '') {\n $this->json(['success' => false, 'error' => 'Name und Typ sind erforderlich'], 400);\n\n return;\n }\n\n try {\n $id = $this->repository->createEntity($name, $type, $description);\n $this->json(['success' => true, 'id' => $id]);\n } catch (\\Exception $e) {\n $this->json(['success' => false, 'error' => $e->getMessage()], 500);\n }\n }\n\n \/**\n * GET \/semantic-explorer\/entitaeten\/{id}\/edit\n *\/\n public function edit(int $id): void\n {\n $entity = $this->repository->getEntity($id);\n\n if ($entity === null) {\n $this->notFound('Entitaet nicht gefunden');\n }\n\n $this->view('semantic-explorer.entitaeten.edit', [\n 'title' => 'Entitaet bearbeiten',\n 'entity' => $entity,\n 'types' => $this->repository->getEntityTypes(),\n ]);\n }\n\n \/**\n * POST \/semantic-explorer\/entitaeten\/{id}\n *\/\n public function update(int $id): void\n {\n $input = json_decode(file_get_contents('php:\/\/input'), true);\n\n $name = trim($input['name'] ?? '');\n $type = trim($input['type'] ?? '');\n $description = trim($input['description'] ?? '') ?: null;\n\n if ($name === '' || $type === '') {\n $this->json(['success' => false, 'error' => 'Name und Typ sind erforderlich'], 400);\n\n return;\n }\n\n try {\n $this->repository->updateEntity($id, $name, $type, $description);\n $this->json(['success' => true]);\n } catch (\\Exception $e) {\n $this->json(['success' => false, 'error' => $e->getMessage()], 500);\n }\n }\n\n \/**\n * POST \/semantic-explorer\/entitaeten\/{id}\/delete\n *\/\n public function delete(int $id): void\n {\n try {\n $success = $this->repository->deleteEntity($id);\n if ($success) {\n $this->json(['success' => true]);\n } else {\n $this->json(['success' => false, 'error' => 'Entitaet hat noch Relationen'], 400);\n }\n } catch (\\Exception $e) {\n $this->json(['success' => false, 'error' => $e->getMessage()], 500);\n }\n }\n}\n",
"structuredPatch": [],
"originalFile": null
}
}