refactor(audit): remove factory chain and repository interfaces
Remove AuditRepositoryFactory and AuditServicesFactory — two-layer factory chain replaced by direct DI container wiring. Delete 4 single-consumer repository interfaces. Register all 4 repositories and SystemAuditRedactionService directly in container. Update all service constructors to type-hint concrete classes. Fix architecture test and documentation references to deleted factories. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -12,12 +12,15 @@ use MintyPHP\Module\Audit\Handler\SystemAuditPurgeJobHandler;
|
||||
use MintyPHP\Module\Audit\Handler\UserLifecycleAuditPurgeJobHandler;
|
||||
use MintyPHP\Module\Audit\Http\ApiSystemAuditReporter;
|
||||
use MintyPHP\Module\Audit\Providers\AuditLayoutProvider;
|
||||
use MintyPHP\Module\Audit\Repository\ApiAuditLogRepository;
|
||||
use MintyPHP\Module\Audit\Repository\ImportAuditRunRepository;
|
||||
use MintyPHP\Module\Audit\Repository\SystemAuditLogRepository;
|
||||
use MintyPHP\Module\Audit\Repository\UserLifecycleAuditRepository;
|
||||
use MintyPHP\Module\Audit\Service\ApiAuditService;
|
||||
use MintyPHP\Module\Audit\Service\AuditMetadataEnricher;
|
||||
use MintyPHP\Module\Audit\Service\AuditRepositoryFactory;
|
||||
use MintyPHP\Module\Audit\Service\AuditServicesFactory;
|
||||
use MintyPHP\Module\Audit\Service\FrontendTelemetryIngestService;
|
||||
use MintyPHP\Module\Audit\Service\ImportAuditService;
|
||||
use MintyPHP\Module\Audit\Service\SystemAuditRedactionService;
|
||||
use MintyPHP\Module\Audit\Service\SystemAuditService;
|
||||
use MintyPHP\Module\Audit\Service\UserLifecycleAuditService;
|
||||
use MintyPHP\Repository\User\UserReadRepository;
|
||||
@@ -27,30 +30,38 @@ use MintyPHP\Service\Audit\AuditRecorderInterface;
|
||||
use MintyPHP\Service\Audit\ImportAuditInterface;
|
||||
use MintyPHP\Service\Audit\UserLifecycleAuditInterface;
|
||||
use MintyPHP\Service\Security\RateLimiterService;
|
||||
use MintyPHP\Service\Settings\SettingServicesFactory;
|
||||
use MintyPHP\Service\Settings\SettingsFrontendTelemetryGateway;
|
||||
use MintyPHP\Service\Settings\SettingsSystemAuditGateway;
|
||||
|
||||
final class AuditContainerRegistrar implements ContainerRegistrar
|
||||
{
|
||||
public function register(AppContainer $container): void
|
||||
{
|
||||
// Repository factory
|
||||
$container->set(AuditRepositoryFactory::class, static fn (): AuditRepositoryFactory => new AuditRepositoryFactory());
|
||||
// Repositories
|
||||
$container->set(SystemAuditLogRepository::class, static fn (): SystemAuditLogRepository => new SystemAuditLogRepository());
|
||||
$container->set(ApiAuditLogRepository::class, static fn (): ApiAuditLogRepository => new ApiAuditLogRepository());
|
||||
$container->set(UserLifecycleAuditRepository::class, static fn (): UserLifecycleAuditRepository => new UserLifecycleAuditRepository());
|
||||
$container->set(ImportAuditRunRepository::class, static fn (): ImportAuditRunRepository => new ImportAuditRunRepository());
|
||||
|
||||
// Services factory
|
||||
$container->set(AuditServicesFactory::class, static fn (AppContainer $c): AuditServicesFactory => new AuditServicesFactory(
|
||||
$c->get(AuditRepositoryFactory::class),
|
||||
$c->get(SettingServicesFactory::class)->createSettingsSystemAuditGateway(),
|
||||
$c->get(RequestRuntimeInterface::class),
|
||||
$c->get(SessionStoreInterface::class)
|
||||
));
|
||||
// Redaction
|
||||
$container->set(SystemAuditRedactionService::class, static fn (): SystemAuditRedactionService => new SystemAuditRedactionService());
|
||||
|
||||
// Concrete audit services
|
||||
$container->set(SystemAuditService::class, static fn (AppContainer $c): SystemAuditService => $c->get(AuditServicesFactory::class)->createSystemAuditService());
|
||||
$container->set(ApiAuditService::class, static fn (AppContainer $c): ApiAuditService => $c->get(AuditServicesFactory::class)->createApiAuditService());
|
||||
$container->set(UserLifecycleAuditService::class, static fn (AppContainer $c): UserLifecycleAuditService => $c->get(AuditServicesFactory::class)->createUserLifecycleAuditService());
|
||||
$container->set(SystemAuditService::class, static fn (AppContainer $c): SystemAuditService => new SystemAuditService(
|
||||
$c->get(SystemAuditLogRepository::class),
|
||||
$c->get(SystemAuditRedactionService::class),
|
||||
$c->get(SettingsSystemAuditGateway::class),
|
||||
$c->get(SessionStoreInterface::class)
|
||||
));
|
||||
$container->set(ApiAuditService::class, static fn (AppContainer $c): ApiAuditService => new ApiAuditService(
|
||||
$c->get(ApiAuditLogRepository::class),
|
||||
$c->get(RequestRuntimeInterface::class)
|
||||
));
|
||||
$container->set(UserLifecycleAuditService::class, static fn (AppContainer $c): UserLifecycleAuditService => new UserLifecycleAuditService(
|
||||
$c->get(UserLifecycleAuditRepository::class)
|
||||
));
|
||||
$container->set(ImportAuditService::class, static fn (AppContainer $c): ImportAuditService => new ImportAuditService(
|
||||
$c->get(AuditRepositoryFactory::class)->createImportAuditRunRepository()
|
||||
$c->get(ImportAuditRunRepository::class)
|
||||
));
|
||||
|
||||
// Core interface bindings — override null implementations
|
||||
|
||||
Reference in New Issue
Block a user