Backup #445

ID445
Dateipfad/var/www/dev.campus.systemische-tools.de/src/Infrastructure/Persistence/ContentConfigRepository.php
Version1
Typ modified
Größe1.9 KB
Hash126679a0954e7570865b48893fa71f4dcc78e9b6aeae760e2eb4d85d9a2fb7ae
Datum2025-12-22 10:17:13
Geändert vonclaude-code-hook
GrundClaude Code Pre-Hook Backup vor Edit-Operation
Datei existiert Ja

Dateiinhalt

<?php

namespace Infrastructure\Persistence;

use Infrastructure\Config\DatabaseFactory;

/**
 * Repository for content_config table.
 *
 * Handles author profiles, system prompts, and other content configurations.
 */
class ContentConfigRepository
{
    private \PDO $pdo;

    public function __construct(?\PDO $pdo = null)
    {
        $this->pdo = $pdo ?? DatabaseFactory::content();
    }

    /**
     * Find config by ID and type
     */
    public function findByIdAndType(int $id, string $type): ?array
    {
        $stmt = $this->pdo->prepare(
            "SELECT id, name, slug, content, type, status
             FROM content_config
             WHERE id = ? AND type = ? AND status = 'active'"
        );
        $stmt->execute([$id, $type]);
        $result = $stmt->fetch(\PDO::FETCH_ASSOC);

        return $result !== false ? $result : null;
    }

    /**
     * Find all configs by type
     */
    public function findAllByType(string $type): array
    {
        $stmt = $this->pdo->prepare(
            "SELECT id, name, slug, content, type, status
             FROM content_config
             WHERE type = ? AND status = 'active'
             ORDER BY name"
        );
        $stmt->execute([$type]);

        return $stmt->fetchAll(\PDO::FETCH_ASSOC);
    }

    /**
     * Get all author profiles
     */
    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');
    }
}

Vollständig herunterladen

Aktionen

Herunterladen

Andere Versionen dieser Datei

ID Version Typ Größe Datum
2132 8 modified 7.1 KB 2025-12-30 20:30
2131 7 modified 7.0 KB 2025-12-30 20:29
1508 6 modified 6.9 KB 2025-12-25 18:19
1205 5 modified 6.9 KB 2025-12-25 10:35
1188 4 modified 7.0 KB 2025-12-25 10:32
781 3 modified 6.9 KB 2025-12-23 08:05
544 2 modified 6.6 KB 2025-12-23 02:37
445 1 modified 1.9 KB 2025-12-22 10:17

← Zurück zur Übersicht