{
"event": "PostToolUse",
"raw_data": {
"session_id": "f0f145c4-ac1d-417a-b15b-271983ae648b",
"transcript_path": "\/root\/.claude\/projects\/-var-www\/f0f145c4-ac1d-417a-b15b-271983ae648b.jsonl",
"cwd": "\/var\/www\/dev.campus.systemische-tools.de",
"permission_mode": "acceptEdits",
"hook_event_name": "PostToolUse",
"tool_name": "Read",
"tool_input": {
"file_path": "\/var\/www\/dev.campus.systemische-tools.de\/src\/Infrastructure\/Persistence\/TaxonomyRepository.php"
},
"tool_response": {
"type": "text",
"file": {
"filePath": "\/var\/www\/dev.campus.systemische-tools.de\/src\/Infrastructure\/Persistence\/TaxonomyRepository.php",
"content": "<?php\n\ndeclare(strict_types=1);\n\nnamespace Infrastructure\\Persistence;\n\n\/\/ @responsibility: CRUD-Operationen für Taxonomy-Begriffe (Hierarchie)\n\nuse Domain\\Repository\\TaxonomyRepositoryInterface;\nuse Infrastructure\\Config\\DatabaseFactory;\nuse PDO;\n\nfinal class TaxonomyRepository implements TaxonomyRepositoryInterface\n{\n private PDO $db;\n\n public function __construct()\n {\n $this->db = DatabaseFactory::content();\n }\n\n \/**\n * {@inheritDoc}\n *\/\n public function findAll(): array\n {\n return $this->db->query(\n 'SELECT t.*,\n COUNT(DISTINCT ct.chunk_id) as chunk_count,\n (SELECT COUNT(*) FROM taxonomy_terms WHERE parent_id = t.id) as children_count\n FROM taxonomy_terms t\n LEFT JOIN chunk_taxonomy ct ON t.id = ct.taxonomy_term_id\n GROUP BY t.id\n ORDER BY t.path, t.name'\n )->fetchAll();\n }\n\n \/**\n * {@inheritDoc}\n *\/\n public function getStats(): array\n {\n $result = $this->db->query(\n 'SELECT\n (SELECT COUNT(*) FROM taxonomy_terms) as total_terms,\n (SELECT COUNT(*) FROM taxonomy_terms WHERE parent_id IS NULL) as root_terms,\n (SELECT MAX(depth) FROM taxonomy_terms) as max_depth,\n (SELECT COUNT(DISTINCT chunk_id) FROM chunk_taxonomy) as tagged_chunks'\n )->fetch();\n\n return $result !== false ? $result : [\n 'total_terms' => 0,\n 'root_terms' => 0,\n 'max_depth' => 0,\n 'tagged_chunks' => 0,\n ];\n }\n\n \/**\n * {@inheritDoc}\n *\/\n public function find(int $id): ?array\n {\n $stmt = $this->db->prepare('SELECT * FROM taxonomy_terms WHERE id = :id');\n $stmt->execute(['id' => $id]);\n $result = $stmt->fetch();\n\n return $result === false ? null : $result;\n }\n\n \/**\n * {@inheritDoc}\n *\/\n public function create(string $name, ?int $parentId = null): int\n {\n $depth = 0;\n $path = $name;\n\n if ($parentId !== null) {\n $parent = $this->find($parentId);\n if ($parent !== null) {\n $depth = $parent['depth'] + 1;\n $path = $parent['path'] . '\/' . $name;\n }\n }\n\n $stmt = $this->db->prepare(\n 'INSERT INTO taxonomy_terms (name, parent_id, depth, path, created_at)\n VALUES (:name, :parent, :depth, :path, NOW())'\n );\n $stmt->execute([\n 'name' => $name,\n 'parent' => $parentId,\n 'depth' => $depth,\n 'path' => $path,\n ]);\n\n return (int) $this->db->lastInsertId();\n }\n\n \/**\n * {@inheritDoc}\n *\/\n public function update(int $id, string $name, ?int $parentId = null): bool\n {\n $depth = 0;\n $path = $name;\n\n if ($parentId !== null) {\n $parent = $this->find($parentId);\n if ($parent !== null) {\n $depth = $parent['depth'] + 1;\n $path = $parent['path'] . '\/' . $name;\n }\n }\n\n $stmt = $this->db->prepare(\n 'UPDATE taxonomy_terms SET name = :name, parent_id = :parent, depth = :depth, path = :path WHERE id = :id'\n );\n\n return $stmt->execute([\n 'id' => $id,\n 'name' => $name,\n 'parent' => $parentId,\n 'depth' => $depth,\n 'path' => $path,\n ]);\n }\n\n \/**\n * {@inheritDoc}\n *\/\n public function delete(int $id): bool\n {\n \/\/ Check for children\n $stmt = $this->db->prepare('SELECT COUNT(*) FROM taxonomy_terms WHERE parent_id = :id');\n $stmt->execute(['id' => $id]);\n\n if ((int) $stmt->fetchColumn() > 0) {\n return false; \/\/ Has children, cannot delete\n }\n\n \/\/ Delete chunk associations\n $stmt = $this->db->prepare('DELETE FROM chunk_taxonomy WHERE taxonomy_term_id = :id');\n $stmt->execute(['id' => $id]);\n\n \/\/ Delete term\n $stmt = $this->db->prepare('DELETE FROM taxonomy_terms WHERE id = :id');\n\n return $stmt->execute(['id' => $id]);\n }\n\n \/**\n * {@inheritDoc}\n *\/\n public function findForSelect(): array\n {\n return $this->db->query(\n 'SELECT id, name, depth, path FROM taxonomy_terms ORDER BY path, name'\n )->fetchAll();\n }\n}\n",
"numLines": 163,
"startLine": 1,
"totalLines": 163
}
},
"tool_use_id": "toolu_01AwhZqRLiTY9DsS1DAb3doF"
}
}