Files
breadcrumb-the-shire/lib/Service/Audit/AuditServicesFactory.php

72 lines
2.5 KiB
PHP
Raw Normal View History

2026-02-23 12:58:19 +01:00
<?php
namespace MintyPHP\Service\Audit;
2026-03-06 00:44:52 +01:00
use MintyPHP\Http\RequestRuntimeInterface;
use MintyPHP\Http\SessionStoreInterface;
2026-03-05 08:26:51 +01:00
use MintyPHP\Repository\Audit\ApiAuditLogRepositoryInterface;
use MintyPHP\Repository\Audit\SystemAuditLogRepositoryInterface;
use MintyPHP\Repository\Audit\UserLifecycleAuditRepositoryInterface;
2026-03-06 00:44:52 +01:00
use MintyPHP\Service\Settings\SettingsSystemAuditGateway;
2026-02-23 12:58:19 +01:00
class AuditServicesFactory
{
private ?ApiAuditService $apiAuditService = null;
private ?UserLifecycleAuditService $userLifecycleAuditService = null;
2026-03-04 15:56:58 +01:00
private ?SystemAuditRedactionService $systemAuditRedactionService = null;
private ?SystemAuditService $systemAuditService = null;
public function __construct(
private readonly AuditRepositoryFactory $auditRepositoryFactory,
2026-03-06 00:44:52 +01:00
private readonly SettingsSystemAuditGateway $settingsSystemAuditGateway,
private readonly RequestRuntimeInterface $requestRuntime,
private readonly SessionStoreInterface $sessionStore
2026-03-05 11:17:42 +01:00
) {
}
2026-02-23 12:58:19 +01:00
2026-03-05 08:26:51 +01:00
public function createApiAuditLogRepository(): ApiAuditLogRepositoryInterface
2026-02-23 12:58:19 +01:00
{
2026-03-04 15:56:58 +01:00
return $this->auditRepositoryFactory->createApiAuditLogRepository();
2026-02-23 12:58:19 +01:00
}
2026-03-05 08:26:51 +01:00
public function createUserLifecycleAuditRepository(): UserLifecycleAuditRepositoryInterface
2026-02-23 12:58:19 +01:00
{
2026-03-04 15:56:58 +01:00
return $this->auditRepositoryFactory->createUserLifecycleAuditRepository();
}
2026-03-05 08:26:51 +01:00
public function createSystemAuditLogRepository(): SystemAuditLogRepositoryInterface
2026-03-04 15:56:58 +01:00
{
return $this->auditRepositoryFactory->createSystemAuditLogRepository();
2026-02-23 12:58:19 +01:00
}
public function createApiAuditService(): ApiAuditService
{
2026-03-06 00:44:52 +01:00
return $this->apiAuditService ??= new ApiAuditService(
$this->createApiAuditLogRepository(),
$this->requestRuntime
);
2026-02-23 12:58:19 +01:00
}
public function createUserLifecycleAuditService(): UserLifecycleAuditService
{
return $this->userLifecycleAuditService ??= new UserLifecycleAuditService(
$this->createUserLifecycleAuditRepository()
);
}
2026-03-04 15:56:58 +01:00
public function createSystemAuditRedactionService(): SystemAuditRedactionService
{
return $this->systemAuditRedactionService ??= new SystemAuditRedactionService();
}
public function createSystemAuditService(): SystemAuditService
{
return $this->systemAuditService ??= new SystemAuditService(
$this->createSystemAuditLogRepository(),
$this->createSystemAuditRedactionService(),
2026-03-06 00:44:52 +01:00
$this->settingsSystemAuditGateway,
$this->sessionStore
2026-03-04 15:56:58 +01:00
);
}
2026-02-23 12:58:19 +01:00
}