Backup #933

ID933
Dateipfad/var/www/dev.campus.systemische-tools.de/src/services.php
Version27
Typ modified
Größe10.8 KB
Hash17775b44d468374180c2b9f6a0af77cf431abe61ceb62736978e32faa8824c7f
Datum2025-12-23 21:45:52
Geändert vonclaude-code-hook
GrundClaude Code Pre-Hook Backup vor Edit-Operation
Datei existiert Ja

Dateiinhalt

<?php

/**
 * Service Definitions for DI Container.
 *
 * All repositories and services are explicitly registered to ensure
 * proper database connections and avoid instantiation in controllers.
 *
 * @param Framework\Container $container
 */

use Application\ContentCollectionService;
use Application\PipelineStepService;
use Domain\Repository\ChatMessageRepositoryInterface;
use Domain\Repository\ChatSessionRepositoryInterface;
use Domain\Repository\CodeAnalysisRepositoryInterface;
use Domain\Repository\CollectionRepositoryInterface;
use Domain\Repository\ContentRepositoryInterface;
use Domain\Repository\DokumentationRepositoryInterface;
use Domain\Repository\PipelineRepositoryInterface;
use Domain\Repository\TaskRepositoryInterface;
use Domain\Service\CodeScannerInterface;
use Framework\Container;
use Infrastructure\AI\AIConfig;
use Infrastructure\AI\ChatService;
use Infrastructure\AI\ContentQualityValidator;
use Infrastructure\AI\ModelRegistry;
use Infrastructure\AI\OllamaService;
use Infrastructure\AI\QdrantService;
use Infrastructure\AI\VectorSearchService;
use Infrastructure\CodeAnalysis\CodeScanner;
use Infrastructure\CodeAnalysis\JsFileParser;
use Infrastructure\CodeAnalysis\PhpFileParser;
use Infrastructure\CodeAnalysis\PythonFileParser;
use Infrastructure\Config\DatabaseFactory;
use Infrastructure\Docs\ChunkAnalysisService;
use Infrastructure\Docs\ChunkingService;
use Infrastructure\Docs\ChunkSyncService;
use Infrastructure\Docs\HybridSearchService;
use Infrastructure\Formatter\ApiResponseFormatter;
use Infrastructure\Formatting\ChatMessageFormatter;
use Infrastructure\Logging\AuditLogger;
use Infrastructure\Persistence\ChatMessageRepository;
use Infrastructure\Persistence\ChatSessionRepository;
use Infrastructure\Persistence\CodeAnalysisRepository;
use Infrastructure\Persistence\CollectionRepository;
use Infrastructure\Persistence\ContentConfigRepository;
use Infrastructure\Persistence\ContentRepository;
use Infrastructure\Persistence\ContractRepository;
use Infrastructure\Persistence\CriticsRepository;
use Infrastructure\Persistence\DokumentationRepository;
use Infrastructure\Persistence\FileBackupRepository;
use Infrastructure\Persistence\KiProtokollRepository;
use Infrastructure\Persistence\PipelineRepository;
use Infrastructure\Persistence\PromptsRepository;
use Infrastructure\Persistence\SystemExplorerRepository;
use Infrastructure\Persistence\TaskAssignmentRepository;
use Infrastructure\Persistence\TaskCommentRepository;
use Infrastructure\Persistence\TaskRepository;
use Infrastructure\Persistence\TaskResultRepository;
use Infrastructure\SemanticExplorerRepository;
use Infrastructure\Validation\CollectionValidator;

// NOTE: UseCases are NOT explicitly registered here.
// They are resolved via Container::autowire() automatically.
// Only register: Interfaces, Services with special config, Repositories.

return function (Container $container): void {
    // =========================================================================
    // DATABASE CONNECTIONS
    // =========================================================================

    // ki_dev database connection
    $container->set('pdo.dev', fn () => DatabaseFactory::dev());

    // ki_content database connection
    $container->set('pdo.content', fn () => DatabaseFactory::content());

    // =========================================================================
    // REPOSITORIES - ki_dev database
    // =========================================================================

    $container->set(SystemExplorerRepository::class, fn () => new SystemExplorerRepository());

    $container->set(DokumentationRepository::class, fn () => new DokumentationRepository());

    $container->set(FileBackupRepository::class, fn () => new FileBackupRepository());

    $container->set(ContractRepository::class, fn () => new ContractRepository());

    $container->set(TaskRepository::class, fn () => new TaskRepository());

    $container->set(TaskAssignmentRepository::class, fn () => new TaskAssignmentRepository());

    $container->set(TaskResultRepository::class, fn () => new TaskResultRepository());

    $container->set(TaskCommentRepository::class, fn () => new TaskCommentRepository());

    $container->set(KiProtokollRepository::class, fn () => new KiProtokollRepository());

    $container->set(CollectionRepository::class, fn () => new CollectionRepository());

    $container->set(PipelineRepository::class, fn () => new PipelineRepository());

    $container->set(CodeAnalysisRepository::class, function (Container $c) {
        return new CodeAnalysisRepository($c->get('pdo.dev'));
    });

    // =========================================================================
    // REPOSITORIES - ki_content database
    // =========================================================================

    $container->set(ContentRepository::class, fn () => new ContentRepository());

    $container->set(SemanticExplorerRepository::class, fn () => new SemanticExplorerRepository());

    $container->set(ChatSessionRepository::class, fn () => new ChatSessionRepository());

    $container->set(ChatMessageRepository::class, fn () => new ChatMessageRepository());

    $container->set(PromptsRepository::class, fn () => new PromptsRepository());

    $container->set(CriticsRepository::class, fn () => new CriticsRepository());

    $container->set(ContentConfigRepository::class, fn () => new ContentConfigRepository());

    // =========================================================================
    // INTERFACE ALIASES (Domain → Infrastructure)
    // =========================================================================

    $container->set(TaskRepositoryInterface::class, fn (Container $c) => $c->get(TaskRepository::class));

    $container->set(ChatSessionRepositoryInterface::class, fn (Container $c) => $c->get(ChatSessionRepository::class));

    $container->set(ChatMessageRepositoryInterface::class, fn (Container $c) => $c->get(ChatMessageRepository::class));

    $container->set(CollectionRepositoryInterface::class, fn (Container $c) => $c->get(CollectionRepository::class));

    $container->set(PipelineRepositoryInterface::class, fn (Container $c) => $c->get(PipelineRepository::class));

    $container->set(ContentRepositoryInterface::class, fn (Container $c) => $c->get(ContentRepository::class));

    $container->set(DokumentationRepositoryInterface::class, fn (Container $c) => $c->get(DokumentationRepository::class));

    $container->set(CodeAnalysisRepositoryInterface::class, fn (Container $c) => $c->get(CodeAnalysisRepository::class));

    // =========================================================================
    // CODE ANALYSIS SERVICES
    // =========================================================================

    $container->set(PhpFileParser::class, fn () => new PhpFileParser());
    $container->set(PythonFileParser::class, fn () => new PythonFileParser());
    $container->set(JsFileParser::class, fn () => new JsFileParser());

    $container->set(CodeScanner::class, function (Container $c) {
        return new CodeScanner(
            $c->get(CodeAnalysisRepository::class),
            $c->get(PhpFileParser::class),
            $c->get(PythonFileParser::class),
            $c->get(JsFileParser::class)
        );
    });

    $container->set(CodeScannerInterface::class, fn (Container $c) => $c->get(CodeScanner::class));

    // =========================================================================
    // AI SERVICES
    // =========================================================================

    $container->set(AIConfig::class, fn () => AIConfig::fromCredentialsFile());

    $container->set(ChatService::class, function (Container $c) {
        return $c->get(AIConfig::class)->createChatService();
    });

    $container->set(OllamaService::class, function (Container $c) {
        return $c->get(AIConfig::class)->createOllamaService();
    });

    $container->set(QdrantService::class, function (Container $c) {
        return $c->get(AIConfig::class)->createQdrantService();
    });

    $container->set(VectorSearchService::class, fn () => new VectorSearchService());

    $container->set(ContentQualityValidator::class, function (Container $c) {
        return new ContentQualityValidator($c->get(OllamaService::class));
    });

    $container->set(ModelRegistry::class, function (Container $c) {
        return new ModelRegistry($c->get('pdo.dev'));
    });

    // =========================================================================
    // APPLICATION SERVICES
    // =========================================================================

    $container->set(AuditLogger::class, fn () => new AuditLogger());

    $container->set(ChunkSyncService::class, function (Container $c) {
        return new ChunkSyncService(
            $c->get('pdo.dev'),
            $c->get(OllamaService::class)
        );
    });

    $container->set(HybridSearchService::class, function (Container $c) {
        return new HybridSearchService(
            $c->get('pdo.dev'),
            $c->get(OllamaService::class)
        );
    });

    $container->set(ChunkAnalysisService::class, function (Container $c) {
        return new ChunkAnalysisService(
            $c->get('pdo.dev'),
            $c->get(OllamaService::class)
        );
    });

    $container->set(ChunkingService::class, function (Container $c) {
        return new ChunkingService(
            $c->get('pdo.dev'),
            $c->get(DokumentationRepository::class)
        );
    });

    $container->set(CollectionValidator::class, function (Container $c) {
        return new CollectionValidator($c->get(CollectionRepository::class));
    });

    $container->set(ContentCollectionService::class, function (Container $c) {
        return new ContentCollectionService(
            $c->get(CollectionRepository::class),
            $c->get(CollectionValidator::class)
        );
    });

    $container->set(PipelineStepService::class, function (Container $c) {
        return new PipelineStepService($c->get(PipelineRepository::class));
    });

    // =========================================================================
    // FORMATTERS
    // =========================================================================

    $container->set(ApiResponseFormatter::class, fn () => new ApiResponseFormatter());

    $container->set(ChatMessageFormatter::class, fn () => new ChatMessageFormatter());

    // =========================================================================
    // USE CASES - Resolved via Autowiring
    // =========================================================================
    // All UseCases are automatically resolved by Container::autowire().
    // Dependencies are injected based on constructor type-hints.
    // No explicit registration needed - just ensure:
    // 1. All interface dependencies have aliases registered above
    // 2. All concrete dependencies are registered or autowirable
};

Vollständig herunterladen

Aktionen

Herunterladen

Andere Versionen dieser Datei

ID Version Typ Größe Datum
1446 93 modified 20.7 KB 2025-12-25 17:00
1444 92 modified 20.6 KB 2025-12-25 17:00
1437 91 modified 20.2 KB 2025-12-25 16:59
1435 90 modified 19.7 KB 2025-12-25 16:59
1434 89 modified 19.5 KB 2025-12-25 16:59
1432 88 modified 19.3 KB 2025-12-25 16:59
1428 87 modified 19.2 KB 2025-12-25 16:59
1423 86 modified 18.8 KB 2025-12-25 16:59
1417 85 modified 18.7 KB 2025-12-25 16:59
1411 84 modified 18.3 KB 2025-12-25 16:58
1408 83 modified 17.9 KB 2025-12-25 16:58
1404 82 modified 17.8 KB 2025-12-25 16:58
1402 81 modified 17.6 KB 2025-12-25 16:58
1307 80 modified 17.6 KB 2025-12-25 13:31
1306 79 modified 17.5 KB 2025-12-25 13:31
1288 78 modified 17.2 KB 2025-12-25 13:02
1287 77 modified 17.1 KB 2025-12-25 13:02
1286 76 modified 17.1 KB 2025-12-25 13:02
1278 75 modified 16.3 KB 2025-12-25 12:53
1277 74 modified 15.9 KB 2025-12-25 12:53
1259 73 modified 16.0 KB 2025-12-25 12:46
1258 72 modified 16.2 KB 2025-12-25 12:46
1257 71 modified 16.2 KB 2025-12-25 12:46
1256 70 modified 16.3 KB 2025-12-25 12:46
1253 69 modified 16.2 KB 2025-12-25 12:45
1252 68 modified 15.8 KB 2025-12-25 12:45
1251 67 modified 15.5 KB 2025-12-25 12:45
1250 66 modified 15.3 KB 2025-12-25 12:45
1249 65 modified 15.1 KB 2025-12-25 12:45
1230 64 modified 14.8 KB 2025-12-25 12:31
1229 63 modified 14.5 KB 2025-12-25 12:31
1228 62 modified 14.4 KB 2025-12-25 12:31
1227 61 modified 14.3 KB 2025-12-25 12:31
1216 60 modified 13.9 KB 2025-12-25 10:41
1213 59 modified 13.9 KB 2025-12-25 10:40
1212 58 modified 13.8 KB 2025-12-25 10:40
1209 57 modified 13.5 KB 2025-12-25 10:36
1208 56 modified 13.3 KB 2025-12-25 10:36
1171 55 modified 13.1 KB 2025-12-25 10:29
1112 54 modified 12.9 KB 2025-12-25 09:23
1111 53 modified 12.8 KB 2025-12-25 09:23
1110 52 modified 12.9 KB 2025-12-25 09:23
1109 51 modified 12.9 KB 2025-12-25 09:23
1108 50 modified 12.9 KB 2025-12-25 09:23
1103 49 modified 12.8 KB 2025-12-25 09:20
1102 48 modified 12.7 KB 2025-12-25 09:20
1101 47 modified 12.6 KB 2025-12-25 09:20
1100 46 modified 12.6 KB 2025-12-25 09:20
1086 45 modified 12.5 KB 2025-12-25 02:29
1085 44 modified 12.4 KB 2025-12-25 02:29
1084 43 modified 12.3 KB 2025-12-25 02:29
1083 42 modified 12.3 KB 2025-12-25 02:29
1075 41 modified 12.1 KB 2025-12-25 02:27
1074 40 modified 11.9 KB 2025-12-25 02:27
1073 39 modified 11.8 KB 2025-12-25 02:26
1072 38 modified 11.7 KB 2025-12-25 02:26
1062 37 modified 11.6 KB 2025-12-25 02:23
1061 36 modified 11.5 KB 2025-12-25 02:23
1060 35 modified 11.5 KB 2025-12-25 02:23
1059 34 modified 11.4 KB 2025-12-25 02:23
1051 33 modified 11.3 KB 2025-12-25 02:20
1050 32 modified 11.2 KB 2025-12-25 02:20
1049 31 modified 11.2 KB 2025-12-25 02:20
1048 30 modified 11.1 KB 2025-12-25 02:20
1026 29 modified 11.0 KB 2025-12-24 20:20
934 28 modified 10.8 KB 2025-12-23 21:45
933 27 modified 10.8 KB 2025-12-23 21:45
920 26 modified 10.6 KB 2025-12-23 21:05
919 25 modified 10.5 KB 2025-12-23 21:04
874 24 modified 9.8 KB 2025-12-23 09:29
873 23 modified 9.6 KB 2025-12-23 09:29
872 22 modified 9.4 KB 2025-12-23 09:29
869 21 modified 9.2 KB 2025-12-23 09:00
868 20 modified 9.1 KB 2025-12-23 09:00
867 19 modified 8.9 KB 2025-12-23 08:58
866 18 modified 8.9 KB 2025-12-23 08:58
861 17 modified 8.1 KB 2025-12-23 08:47
860 16 modified 8.0 KB 2025-12-23 08:47
850 15 modified 12.3 KB 2025-12-23 08:30
849 14 modified 12.9 KB 2025-12-23 08:30
848 13 modified 11.7 KB 2025-12-23 08:23
847 12 modified 10.5 KB 2025-12-23 08:22
846 11 modified 10.3 KB 2025-12-23 08:22
845 10 modified 9.6 KB 2025-12-23 08:22
844 9 modified 9.3 KB 2025-12-23 08:22
645 8 modified 8.5 KB 2025-12-23 04:47
644 7 modified 8.1 KB 2025-12-23 04:47
610 6 modified 7.2 KB 2025-12-23 04:41
609 5 modified 6.8 KB 2025-12-23 04:41
604 4 modified 1.1 KB 2025-12-23 04:38
584 3 modified 1.1 KB 2025-12-23 04:23
583 2 modified 1.1 KB 2025-12-23 04:23
526 1 modified 1.0 KB 2025-12-22 16:47

← Zurück zur Übersicht