Protokoll #4566

ID4566
Zeitstempel2025-12-22 10:17:13.847687
Clientroot
IP145.224.96.190
Modellclaude-sonnet-4-20250514
Statuscompleted
Tokens7,145 (Input: 2,329, Output: 4,816)
Dauer95 ms
Request-Zeit2025-12-22 10:17:13.847687
Response-Zeit2025-12-22 10:17:13.942242

Request

{
    "event": "PreToolUse",
    "tool_name": "Edit",
    "tool_input": {
        "file_path": "\/var\/www\/dev.campus.systemische-tools.de\/src\/Infrastructure\/Persistence\/ContentConfigRepository.php",
        "old_string": "<?php\n\nnamespace Infrastructure\\Persistence;\n\nuse Infrastructure\\Config\\DatabaseFactory;\n\n\/**\n * Repository for content_config table.\n *\n * Handles author profiles, system prompts, and other content configurations.\n *\/\nclass ContentConfigRepository\n{\n    private \\PDO $pdo;\n\n    public function __construct(?\\PDO $pdo = null)\n    {\n        $this->pdo = $pdo ?? DatabaseFactory::content();\n    }\n\n    \/**\n     * Find config by ID and type\n     *\/\n    public function findByIdAndType(int $id, string $type): ?array\n    {\n        $stmt = $this->pdo->prepare(\n            \"SELECT id, name, slug, content, type, status\n             FROM content_config\n             WHERE id = ? AND type = ? AND status = 'active'\"\n        );\n        $stmt->execute([$id, $type]);\n        $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n\n        return $result !== false ? $result : null;\n    }\n\n    \/**\n     * Find all configs by type\n     *\/\n    public function findAllByType(string $type): array\n    {\n        $stmt = $this->pdo->prepare(\n            \"SELECT id, name, slug, content, type, status\n             FROM content_config\n             WHERE type = ? AND status = 'active'\n             ORDER BY name\"\n        );\n        $stmt->execute([$type]);\n\n        return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n    }\n\n    \/**\n     * Get all author profiles\n     *\/\n    public function getAuthorProfiles(): array\n    {\n        return $this->findAllByType('author_profile');\n    }\n\n    \/**\n     * Get all system prompts\n     *\/\n    public function getSystemPrompts(): array\n    {\n        return $this->findAllByType('system_prompt');\n    }\n\n    \/**\n     * Get author profile by ID\n     *\/\n    public function getAuthorProfile(int $id): ?array\n    {\n        return $this->findByIdAndType($id, 'author_profile');\n    }\n\n    \/**\n     * Get system prompt by ID\n     *\/\n    public function getSystemPrompt(int $id): ?array\n    {\n        return $this->findByIdAndType($id, 'system_prompt');\n    }\n}",
        "new_string": "<?php\n\nnamespace Infrastructure\\Persistence;\n\nuse Infrastructure\\Config\\DatabaseFactory;\n\nclass ContentConfigRepository\n{\n    private \\PDO $pdo;\n\n    public function __construct(?\\PDO $pdo = null)\n    {\n        $this->pdo = $pdo ?? DatabaseFactory::content();\n    }\n\n    public function findById(int $id): ?array\n    {\n        $stmt = $this->pdo->prepare(\n            'SELECT c.*, p.name as parent_name\n             FROM content_config c\n             LEFT JOIN content_config p ON c.parent_id = p.id\n             WHERE c.id = ?'\n        );\n        $stmt->execute([$id]);\n        $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n\n        return $result !== false ? $result : null;\n    }\n\n    public function findByIdAndType(int $id, string $type): ?array\n    {\n        $stmt = $this->pdo->prepare(\n            \"SELECT id, name, slug, content, type, status\n             FROM content_config\n             WHERE id = ? AND type = ? AND status = 'active'\"\n        );\n        $stmt->execute([$id, $type]);\n        $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n\n        return $result !== false ? $result : null;\n    }\n\n    public function findAll(?string $typeFilter = null, ?string $statusFilter = null): array\n    {\n        $sql = 'SELECT c.*, p.name as parent_name\n                FROM content_config c\n                LEFT JOIN content_config p ON c.parent_id = p.id\n                WHERE 1=1';\n        $params = [];\n\n        if ($typeFilter !== null && $typeFilter !== '') {\n            $sql .= ' AND c.type = ?';\n            $params[] = $typeFilter;\n        }\n\n        if ($statusFilter !== null && $statusFilter !== '') {\n            $sql .= ' AND c.status = ?';\n            $params[] = $statusFilter;\n        }\n\n        $sql .= ' ORDER BY c.type, c.name';\n\n        $stmt = $this->pdo->prepare($sql);\n        $stmt->execute($params);\n\n        return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n    }\n\n    public function findAllByType(string $type): array\n    {\n        $stmt = $this->pdo->prepare(\n            \"SELECT id, name, slug, content, type, status\n             FROM content_config\n             WHERE type = ? AND status = 'active'\n             ORDER BY name\"\n        );\n        $stmt->execute([$type]);\n\n        return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n    }\n\n    public function create(\n        string $type,\n        string $name,\n        string $slug,\n        ?string $description,\n        string $content,\n        string $version,\n        string $status,\n        ?int $parentId\n    ): int {\n        $stmt = $this->pdo->prepare(\n            'INSERT INTO content_config (type, name, slug, description, content, version, status, parent_id)\n             VALUES (?, ?, ?, ?, ?, ?, ?, ?)'\n        );\n        $stmt->execute([$type, $name, $slug, $description, $content, $version, $status, $parentId]);\n\n        return (int) $this->pdo->lastInsertId();\n    }\n\n    public function update(\n        int $id,\n        string $name,\n        string $slug,\n        ?string $description,\n        string $content,\n        string $version,\n        string $status,\n        ?int $parentId\n    ): void {\n        $stmt = $this->pdo->prepare(\n            'UPDATE content_config\n             SET name = ?, slug = ?, description = ?, content = ?, version = ?, status = ?, parent_id = ?\n             WHERE id = ?'\n        );\n        $stmt->execute([$name, $slug, $description, $content, $version, $status, $parentId, $id]);\n    }\n\n    public function delete(int $id): void\n    {\n        $stmt = $this->pdo->prepare('DELETE FROM content_config WHERE id = ?');\n        $stmt->execute([$id]);\n    }\n\n    public function saveHistory(int $configId, string $content, string $version, string $changedBy, string $changeDescription): void\n    {\n        $stmt = $this->pdo->prepare(\n            'INSERT INTO content_config_history (config_id, content, version, changed_by, change_description)\n             VALUES (?, ?, ?, ?, ?)'\n        );\n        $stmt->execute([$configId, $content, $version, $changedBy, $changeDescription]);\n    }\n\n    public function deleteHistory(int $configId): void\n    {\n        $stmt = $this->pdo->prepare('DELETE FROM content_config_history WHERE config_id = ?');\n        $stmt->execute([$configId]);\n    }\n\n    public function countChildren(int $parentId): int\n    {\n        $stmt = $this->pdo->prepare('SELECT COUNT(*) FROM content_config WHERE parent_id = ?');\n        $stmt->execute([$parentId]);\n\n        return (int) $stmt->fetchColumn();\n    }\n\n    public function getChildren(int $parentId): array\n    {\n        $stmt = $this->pdo->prepare('SELECT * FROM content_config WHERE parent_id = ? ORDER BY name');\n        $stmt->execute([$parentId]);\n\n        return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n    }\n\n    public function getHistory(int $configId, int $limit = 10): array\n    {\n        $stmt = $this->pdo->prepare(\n            'SELECT * FROM content_config_history WHERE config_id = ? ORDER BY created_at DESC LIMIT ?'\n        );\n        $stmt->bindValue(1, $configId, \\PDO::PARAM_INT);\n        $stmt->bindValue(2, $limit, \\PDO::PARAM_INT);\n        $stmt->execute();\n\n        return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n    }\n\n    public function getParentOptions(?int $excludeId = null): array\n    {\n        $stmt = $this->pdo->query(\n            'SELECT id, type, name FROM content_config WHERE type IN (\"contract\", \"organization\") ORDER BY type, name'\n        );\n        $parents = [];\n        foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n            if ($excludeId !== null && (int) $row['id'] === $excludeId) {\n                continue;\n            }\n            $parents[] = $row;\n        }\n\n        return $parents;\n    }\n\n    public function getStatistics(): array\n    {\n        $stats = ['total' => 0, 'by_type' => [], 'by_status' => []];\n\n        $stmt = $this->pdo->query('SELECT type, COUNT(*) as cnt FROM content_config GROUP BY type');\n        foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n            $stats['by_type'][$row['type']] = (int) $row['cnt'];\n            $stats['total'] += (int) $row['cnt'];\n        }\n\n        $stmt = $this->pdo->query('SELECT status, COUNT(*) as cnt FROM content_config GROUP BY status');\n        foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n            $stats['by_status'][$row['status']] = (int) $row['cnt'];\n        }\n\n        return $stats;\n    }\n\n    public function getAuthorProfiles(): array\n    {\n        return $this->findAllByType('author_profile');\n    }\n\n    public function getSystemPrompts(): array\n    {\n        return $this->findAllByType('system_prompt');\n    }\n\n    public function getAuthorProfile(int $id): ?array\n    {\n        return $this->findByIdAndType($id, 'author_profile');\n    }\n\n    public function getSystemPrompt(int $id): ?array\n    {\n        return $this->findByIdAndType($id, 'system_prompt');\n    }\n}"
    }
}

Response

{
    "tool_response": {
        "filePath": "\/var\/www\/dev.campus.systemische-tools.de\/src\/Infrastructure\/Persistence\/ContentConfigRepository.php",
        "oldString": "<?php\n\nnamespace Infrastructure\\Persistence;\n\nuse Infrastructure\\Config\\DatabaseFactory;\n\n\/**\n * Repository for content_config table.\n *\n * Handles author profiles, system prompts, and other content configurations.\n *\/\nclass ContentConfigRepository\n{\n    private \\PDO $pdo;\n\n    public function __construct(?\\PDO $pdo = null)\n    {\n        $this->pdo = $pdo ?? DatabaseFactory::content();\n    }\n\n    \/**\n     * Find config by ID and type\n     *\/\n    public function findByIdAndType(int $id, string $type): ?array\n    {\n        $stmt = $this->pdo->prepare(\n            \"SELECT id, name, slug, content, type, status\n             FROM content_config\n             WHERE id = ? AND type = ? AND status = 'active'\"\n        );\n        $stmt->execute([$id, $type]);\n        $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n\n        return $result !== false ? $result : null;\n    }\n\n    \/**\n     * Find all configs by type\n     *\/\n    public function findAllByType(string $type): array\n    {\n        $stmt = $this->pdo->prepare(\n            \"SELECT id, name, slug, content, type, status\n             FROM content_config\n             WHERE type = ? AND status = 'active'\n             ORDER BY name\"\n        );\n        $stmt->execute([$type]);\n\n        return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n    }\n\n    \/**\n     * Get all author profiles\n     *\/\n    public function getAuthorProfiles(): array\n    {\n        return $this->findAllByType('author_profile');\n    }\n\n    \/**\n     * Get all system prompts\n     *\/\n    public function getSystemPrompts(): array\n    {\n        return $this->findAllByType('system_prompt');\n    }\n\n    \/**\n     * Get author profile by ID\n     *\/\n    public function getAuthorProfile(int $id): ?array\n    {\n        return $this->findByIdAndType($id, 'author_profile');\n    }\n\n    \/**\n     * Get system prompt by ID\n     *\/\n    public function getSystemPrompt(int $id): ?array\n    {\n        return $this->findByIdAndType($id, 'system_prompt');\n    }\n}",
        "newString": "<?php\n\nnamespace Infrastructure\\Persistence;\n\nuse Infrastructure\\Config\\DatabaseFactory;\n\nclass ContentConfigRepository\n{\n    private \\PDO $pdo;\n\n    public function __construct(?\\PDO $pdo = null)\n    {\n        $this->pdo = $pdo ?? DatabaseFactory::content();\n    }\n\n    public function findById(int $id): ?array\n    {\n        $stmt = $this->pdo->prepare(\n            'SELECT c.*, p.name as parent_name\n             FROM content_config c\n             LEFT JOIN content_config p ON c.parent_id = p.id\n             WHERE c.id = ?'\n        );\n        $stmt->execute([$id]);\n        $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n\n        return $result !== false ? $result : null;\n    }\n\n    public function findByIdAndType(int $id, string $type): ?array\n    {\n        $stmt = $this->pdo->prepare(\n            \"SELECT id, name, slug, content, type, status\n             FROM content_config\n             WHERE id = ? AND type = ? AND status = 'active'\"\n        );\n        $stmt->execute([$id, $type]);\n        $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n\n        return $result !== false ? $result : null;\n    }\n\n    public function findAll(?string $typeFilter = null, ?string $statusFilter = null): array\n    {\n        $sql = 'SELECT c.*, p.name as parent_name\n                FROM content_config c\n                LEFT JOIN content_config p ON c.parent_id = p.id\n                WHERE 1=1';\n        $params = [];\n\n        if ($typeFilter !== null && $typeFilter !== '') {\n            $sql .= ' AND c.type = ?';\n            $params[] = $typeFilter;\n        }\n\n        if ($statusFilter !== null && $statusFilter !== '') {\n            $sql .= ' AND c.status = ?';\n            $params[] = $statusFilter;\n        }\n\n        $sql .= ' ORDER BY c.type, c.name';\n\n        $stmt = $this->pdo->prepare($sql);\n        $stmt->execute($params);\n\n        return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n    }\n\n    public function findAllByType(string $type): array\n    {\n        $stmt = $this->pdo->prepare(\n            \"SELECT id, name, slug, content, type, status\n             FROM content_config\n             WHERE type = ? AND status = 'active'\n             ORDER BY name\"\n        );\n        $stmt->execute([$type]);\n\n        return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n    }\n\n    public function create(\n        string $type,\n        string $name,\n        string $slug,\n        ?string $description,\n        string $content,\n        string $version,\n        string $status,\n        ?int $parentId\n    ): int {\n        $stmt = $this->pdo->prepare(\n            'INSERT INTO content_config (type, name, slug, description, content, version, status, parent_id)\n             VALUES (?, ?, ?, ?, ?, ?, ?, ?)'\n        );\n        $stmt->execute([$type, $name, $slug, $description, $content, $version, $status, $parentId]);\n\n        return (int) $this->pdo->lastInsertId();\n    }\n\n    public function update(\n        int $id,\n        string $name,\n        string $slug,\n        ?string $description,\n        string $content,\n        string $version,\n        string $status,\n        ?int $parentId\n    ): void {\n        $stmt = $this->pdo->prepare(\n            'UPDATE content_config\n             SET name = ?, slug = ?, description = ?, content = ?, version = ?, status = ?, parent_id = ?\n             WHERE id = ?'\n        );\n        $stmt->execute([$name, $slug, $description, $content, $version, $status, $parentId, $id]);\n    }\n\n    public function delete(int $id): void\n    {\n        $stmt = $this->pdo->prepare('DELETE FROM content_config WHERE id = ?');\n        $stmt->execute([$id]);\n    }\n\n    public function saveHistory(int $configId, string $content, string $version, string $changedBy, string $changeDescription): void\n    {\n        $stmt = $this->pdo->prepare(\n            'INSERT INTO content_config_history (config_id, content, version, changed_by, change_description)\n             VALUES (?, ?, ?, ?, ?)'\n        );\n        $stmt->execute([$configId, $content, $version, $changedBy, $changeDescription]);\n    }\n\n    public function deleteHistory(int $configId): void\n    {\n        $stmt = $this->pdo->prepare('DELETE FROM content_config_history WHERE config_id = ?');\n        $stmt->execute([$configId]);\n    }\n\n    public function countChildren(int $parentId): int\n    {\n        $stmt = $this->pdo->prepare('SELECT COUNT(*) FROM content_config WHERE parent_id = ?');\n        $stmt->execute([$parentId]);\n\n        return (int) $stmt->fetchColumn();\n    }\n\n    public function getChildren(int $parentId): array\n    {\n        $stmt = $this->pdo->prepare('SELECT * FROM content_config WHERE parent_id = ? ORDER BY name');\n        $stmt->execute([$parentId]);\n\n        return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n    }\n\n    public function getHistory(int $configId, int $limit = 10): array\n    {\n        $stmt = $this->pdo->prepare(\n            'SELECT * FROM content_config_history WHERE config_id = ? ORDER BY created_at DESC LIMIT ?'\n        );\n        $stmt->bindValue(1, $configId, \\PDO::PARAM_INT);\n        $stmt->bindValue(2, $limit, \\PDO::PARAM_INT);\n        $stmt->execute();\n\n        return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n    }\n\n    public function getParentOptions(?int $excludeId = null): array\n    {\n        $stmt = $this->pdo->query(\n            'SELECT id, type, name FROM content_config WHERE type IN (\"contract\", \"organization\") ORDER BY type, name'\n        );\n        $parents = [];\n        foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n            if ($excludeId !== null && (int) $row['id'] === $excludeId) {\n                continue;\n            }\n            $parents[] = $row;\n        }\n\n        return $parents;\n    }\n\n    public function getStatistics(): array\n    {\n        $stats = ['total' => 0, 'by_type' => [], 'by_status' => []];\n\n        $stmt = $this->pdo->query('SELECT type, COUNT(*) as cnt FROM content_config GROUP BY type');\n        foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n            $stats['by_type'][$row['type']] = (int) $row['cnt'];\n            $stats['total'] += (int) $row['cnt'];\n        }\n\n        $stmt = $this->pdo->query('SELECT status, COUNT(*) as cnt FROM content_config GROUP BY status');\n        foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {\n            $stats['by_status'][$row['status']] = (int) $row['cnt'];\n        }\n\n        return $stats;\n    }\n\n    public function getAuthorProfiles(): array\n    {\n        return $this->findAllByType('author_profile');\n    }\n\n    public function getSystemPrompts(): array\n    {\n        return $this->findAllByType('system_prompt');\n    }\n\n    public function getAuthorProfile(int $id): ?array\n    {\n        return $this->findByIdAndType($id, 'author_profile');\n    }\n\n    public function getSystemPrompt(int $id): ?array\n    {\n        return $this->findByIdAndType($id, 'system_prompt');\n    }\n}",
        "originalFile": "<?php\n\nnamespace Infrastructure\\Persistence;\n\nuse Infrastructure\\Config\\DatabaseFactory;\n\n\/**\n * Repository for content_config table.\n *\n * Handles author profiles, system prompts, and other content configurations.\n *\/\nclass ContentConfigRepository\n{\n    private \\PDO $pdo;\n\n    public function __construct(?\\PDO $pdo = null)\n    {\n        $this->pdo = $pdo ?? DatabaseFactory::content();\n    }\n\n    \/**\n     * Find config by ID and type\n     *\/\n    public function findByIdAndType(int $id, string $type): ?array\n    {\n        $stmt = $this->pdo->prepare(\n            \"SELECT id, name, slug, content, type, status\n             FROM content_config\n             WHERE id = ? AND type = ? AND status = 'active'\"\n        );\n        $stmt->execute([$id, $type]);\n        $result = $stmt->fetch(\\PDO::FETCH_ASSOC);\n\n        return $result !== false ? $result : null;\n    }\n\n    \/**\n     * Find all configs by type\n     *\/\n    public function findAllByType(string $type): array\n    {\n        $stmt = $this->pdo->prepare(\n            \"SELECT id, name, slug, content, type, status\n             FROM content_config\n             WHERE type = ? AND status = 'active'\n             ORDER BY name\"\n        );\n        $stmt->execute([$type]);\n\n        return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n    }\n\n    \/**\n     * Get all author profiles\n     *\/\n    public function getAuthorProfiles(): array\n    {\n        return $this->findAllByType('author_profile');\n    }\n\n    \/**\n     * Get all system prompts\n     *\/\n    public function getSystemPrompts(): array\n    {\n        return $this->findAllByType('system_prompt');\n    }\n\n    \/**\n     * Get author profile by ID\n     *\/\n    public function getAuthorProfile(int $id): ?array\n    {\n        return $this->findByIdAndType($id, 'author_profile');\n    }\n\n    \/**\n     * Get system prompt by ID\n     *\/\n    public function getSystemPrompt(int $id): ?array\n    {\n        return $this->findByIdAndType($id, 'system_prompt');\n    }\n}\n",
        "structuredPatch": [
            {
                "oldStart": 4,
                "oldLines": 11,
                "newStart": 4,
                "newLines": 6,
                "lines": [
                    " ",
                    " use Infrastructure\\Config\\DatabaseFactory;",
                    " ",
                    "-\/**",
                    "- * Repository for content_config table.",
                    "- *",
                    "- * Handles author profiles, system prompts, and other content configurations.",
                    "- *\/",
                    " class ContentConfigRepository",
                    " {",
                    "     private \\PDO $pdo;"
                ]
            },
            {
                "oldStart": 18,
                "oldLines": 9,
                "newStart": 13,
                "newLines": 20,
                "lines": [
                    "         $this->pdo = $pdo ?? DatabaseFactory::content();",
                    "     }",
                    " ",
                    "-    \/**",
                    "-     * Find config by ID and type",
                    "-     *\/",
                    "+    public function findById(int $id): ?array",
                    "+    {",
                    "+        $stmt = $this->pdo->prepare(",
                    "+            'SELECT c.*, p.name as parent_name",
                    "+             FROM content_config c",
                    "+             LEFT JOIN content_config p ON c.parent_id = p.id",
                    "+             WHERE c.id = ?'",
                    "+        );",
                    "+        $stmt->execute([$id]);",
                    "+        $result = $stmt->fetch(\\PDO::FETCH_ASSOC);",
                    "+",
                    "+        return $result !== false ? $result : null;",
                    "+    }",
                    "+",
                    "     public function findByIdAndType(int $id, string $type): ?array",
                    "     {",
                    "         $stmt = $this->pdo->prepare("
                ]
            },
            {
                "oldStart": 34,
                "oldLines": 9,
                "newStart": 40,
                "newLines": 32,
                "lines": [
                    "         return $result !== false ? $result : null;",
                    "     }",
                    " ",
                    "-    \/**",
                    "-     * Find all configs by type",
                    "-     *\/",
                    "+    public function findAll(?string $typeFilter = null, ?string $statusFilter = null): array",
                    "+    {",
                    "+        $sql = 'SELECT c.*, p.name as parent_name",
                    "+                FROM content_config c",
                    "+                LEFT JOIN content_config p ON c.parent_id = p.id",
                    "+                WHERE 1=1';",
                    "+        $params = [];",
                    "+",
                    "+        if ($typeFilter !== null && $typeFilter !== '') {",
                    "+            $sql .= ' AND c.type = ?';",
                    "+            $params[] = $typeFilter;",
                    "+        }",
                    "+",
                    "+        if ($statusFilter !== null && $statusFilter !== '') {",
                    "+            $sql .= ' AND c.status = ?';",
                    "+            $params[] = $statusFilter;",
                    "+        }",
                    "+",
                    "+        $sql .= ' ORDER BY c.type, c.name';",
                    "+",
                    "+        $stmt = $this->pdo->prepare($sql);",
                    "+        $stmt->execute($params);",
                    "+",
                    "+        return $stmt->fetchAll(\\PDO::FETCH_ASSOC);",
                    "+    }",
                    "+",
                    "     public function findAllByType(string $type): array",
                    "     {",
                    "         $stmt = $this->pdo->prepare("
                ]
            },
            {
                "oldStart": 50,
                "oldLines": 33,
                "newStart": 79,
                "newLines": 141,
                "lines": [
                    "         return $stmt->fetchAll(\\PDO::FETCH_ASSOC);",
                    "     }",
                    " ",
                    "-    \/**",
                    "-     * Get all author profiles",
                    "-     *\/",
                    "+    public function create(",
                    "+        string $type,",
                    "+        string $name,",
                    "+        string $slug,",
                    "+        ?string $description,",
                    "+        string $content,",
                    "+        string $version,",
                    "+        string $status,",
                    "+        ?int $parentId",
                    "+    ): int {",
                    "+        $stmt = $this->pdo->prepare(",
                    "+            'INSERT INTO content_config (type, name, slug, description, content, version, status, parent_id)",
                    "+             VALUES (?, ?, ?, ?, ?, ?, ?, ?)'",
                    "+        );",
                    "+        $stmt->execute([$type, $name, $slug, $description, $content, $version, $status, $parentId]);",
                    "+",
                    "+        return (int) $this->pdo->lastInsertId();",
                    "+    }",
                    "+",
                    "+    public function update(",
                    "+        int $id,",
                    "+        string $name,",
                    "+        string $slug,",
                    "+        ?string $description,",
                    "+        string $content,",
                    "+        string $version,",
                    "+        string $status,",
                    "+        ?int $parentId",
                    "+    ): void {",
                    "+        $stmt = $this->pdo->prepare(",
                    "+            'UPDATE content_config",
                    "+             SET name = ?, slug = ?, description = ?, content = ?, version = ?, status = ?, parent_id = ?",
                    "+             WHERE id = ?'",
                    "+        );",
                    "+        $stmt->execute([$name, $slug, $description, $content, $version, $status, $parentId, $id]);",
                    "+    }",
                    "+",
                    "+    public function delete(int $id): void",
                    "+    {",
                    "+        $stmt = $this->pdo->prepare('DELETE FROM content_config WHERE id = ?');",
                    "+        $stmt->execute([$id]);",
                    "+    }",
                    "+",
                    "+    public function saveHistory(int $configId, string $content, string $version, string $changedBy, string $changeDescription): void",
                    "+    {",
                    "+        $stmt = $this->pdo->prepare(",
                    "+            'INSERT INTO content_config_history (config_id, content, version, changed_by, change_description)",
                    "+             VALUES (?, ?, ?, ?, ?)'",
                    "+        );",
                    "+        $stmt->execute([$configId, $content, $version, $changedBy, $changeDescription]);",
                    "+    }",
                    "+",
                    "+    public function deleteHistory(int $configId): void",
                    "+    {",
                    "+        $stmt = $this->pdo->prepare('DELETE FROM content_config_history WHERE config_id = ?');",
                    "+        $stmt->execute([$configId]);",
                    "+    }",
                    "+",
                    "+    public function countChildren(int $parentId): int",
                    "+    {",
                    "+        $stmt = $this->pdo->prepare('SELECT COUNT(*) FROM content_config WHERE parent_id = ?');",
                    "+        $stmt->execute([$parentId]);",
                    "+",
                    "+        return (int) $stmt->fetchColumn();",
                    "+    }",
                    "+",
                    "+    public function getChildren(int $parentId): array",
                    "+    {",
                    "+        $stmt = $this->pdo->prepare('SELECT * FROM content_config WHERE parent_id = ? ORDER BY name');",
                    "+        $stmt->execute([$parentId]);",
                    "+",
                    "+        return $stmt->fetchAll(\\PDO::FETCH_ASSOC);",
                    "+    }",
                    "+",
                    "+    public function getHistory(int $configId, int $limit = 10): array",
                    "+    {",
                    "+        $stmt = $this->pdo->prepare(",
                    "+            'SELECT * FROM content_config_history WHERE config_id = ? ORDER BY created_at DESC LIMIT ?'",
                    "+        );",
                    "+        $stmt->bindValue(1, $configId, \\PDO::PARAM_INT);",
                    "+        $stmt->bindValue(2, $limit, \\PDO::PARAM_INT);",
                    "+        $stmt->execute();",
                    "+",
                    "+        return $stmt->fetchAll(\\PDO::FETCH_ASSOC);",
                    "+    }",
                    "+",
                    "+    public function getParentOptions(?int $excludeId = null): array",
                    "+    {",
                    "+        $stmt = $this->pdo->query(",
                    "+            'SELECT id, type, name FROM content_config WHERE type IN (\"contract\", \"organization\") ORDER BY type, name'",
                    "+        );",
                    "+        $parents = [];",
                    "+        foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {",
                    "+            if ($excludeId !== null && (int) $row['id'] === $excludeId) {",
                    "+                continue;",
                    "+            }",
                    "+            $parents[] = $row;",
                    "+        }",
                    "+",
                    "+        return $parents;",
                    "+    }",
                    "+",
                    "+    public function getStatistics(): array",
                    "+    {",
                    "+        $stats = ['total' => 0, 'by_type' => [], 'by_status' => []];",
                    "+",
                    "+        $stmt = $this->pdo->query('SELECT type, COUNT(*) as cnt FROM content_config GROUP BY type');",
                    "+        foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {",
                    "+            $stats['by_type'][$row['type']] = (int) $row['cnt'];",
                    "+            $stats['total'] += (int) $row['cnt'];",
                    "+        }",
                    "+",
                    "+        $stmt = $this->pdo->query('SELECT status, COUNT(*) as cnt FROM content_config GROUP BY status');",
                    "+        foreach ($stmt->fetchAll(\\PDO::FETCH_ASSOC) as $row) {",
                    "+            $stats['by_status'][$row['status']] = (int) $row['cnt'];",
                    "+        }",
                    "+",
                    "+        return $stats;",
                    "+    }",
                    "+",
                    "     public function getAuthorProfiles(): array",
                    "     {",
                    "         return $this->findAllByType('author_profile');",
                    "     }",
                    " ",
                    "-    \/**",
                    "-     * Get all system prompts",
                    "-     *\/",
                    "     public function getSystemPrompts(): array",
                    "     {",
                    "         return $this->findAllByType('system_prompt');",
                    "     }",
                    " ",
                    "-    \/**",
                    "-     * Get author profile by ID",
                    "-     *\/",
                    "     public function getAuthorProfile(int $id): ?array",
                    "     {",
                    "         return $this->findByIdAndType($id, 'author_profile');",
                    "     }",
                    " ",
                    "-    \/**",
                    "-     * Get system prompt by ID",
                    "-     *\/",
                    "     public function getSystemPrompt(int $id): ?array",
                    "     {",
                    "         return $this->findByIdAndType($id, 'system_prompt');"
                ]
            }
        ],
        "userModified": false,
        "replaceAll": false
    }
}
← Vorheriger Zur Liste Nächster →