2026-02-23 12:58:19 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
namespace MintyPHP\Service\Import;
|
|
|
|
|
|
2026-03-06 00:44:52 +01:00
|
|
|
use MintyPHP\Http\SessionStoreInterface;
|
2026-02-23 12:58:19 +01:00
|
|
|
use MintyPHP\Service\Access\AccessServicesFactory;
|
2026-03-13 11:31:33 +01:00
|
|
|
use MintyPHP\Service\Access\PermissionService;
|
refactor(audit): extract audit domain into self-contained module
Move the entire audit subsystem (system audit, API audit, import audit,
user lifecycle audit, frontend telemetry) from core into modules/audit/.
Core decoupling via interface-based injection:
- AuditRecorderInterface replaces SystemAuditService in 10+ core services
- UserLifecycleAuditInterface / ImportAuditInterface for specialized flows
- NullAuditRecorder fallback when audit module is disabled
- ApiBootstrap/ApiResponse use null-safe callable resolvers
Module structure (modules/audit/):
- Manifest with routes, permissions, scheduler jobs, authorization policy
- 9 services, 8 repositories, 6 domain enums, 4 job handlers
- 33 page files, 4 JS files, 8 test files, migration scripts, i18n
Core cleanup:
- OperationsAuthorizationPolicy, UiCapabilityMap, PermissionService
surgically cleaned of audit-specific constants
- Sidebar template cleared of hardcoded audit navigation
- AuditModuleIsolationContractTest ensures no future core→module coupling
All quality gates pass: 1346 tests (19,276 assertions), PHPStan level 5
clean, architecture contracts verified.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-25 21:12:49 +01:00
|
|
|
use MintyPHP\Service\Audit\ImportAuditInterface;
|
2026-03-04 15:56:58 +01:00
|
|
|
use MintyPHP\Service\Directory\DirectoryServicesFactory;
|
2026-02-23 12:58:19 +01:00
|
|
|
use MintyPHP\Service\Import\Profile\DepartmentImportGateway;
|
|
|
|
|
use MintyPHP\Service\Import\Profile\DepartmentImportProfile;
|
|
|
|
|
use MintyPHP\Service\Import\Profile\UserImportGateway;
|
|
|
|
|
use MintyPHP\Service\Import\Profile\UserImportProfile;
|
2026-03-06 00:44:52 +01:00
|
|
|
use MintyPHP\Service\Settings\SettingsDefaultsGateway;
|
2026-02-23 12:58:19 +01:00
|
|
|
use MintyPHP\Service\Settings\SettingServicesFactory;
|
2026-03-13 11:31:33 +01:00
|
|
|
use MintyPHP\Service\Tenant\TenantScopeService;
|
2026-02-23 12:58:19 +01:00
|
|
|
use MintyPHP\Service\User\UserServicesFactory;
|
|
|
|
|
|
|
|
|
|
class ImportServicesFactory
|
|
|
|
|
{
|
|
|
|
|
private ?CsvReaderService $csvReaderService = null;
|
|
|
|
|
private ?ImportTempFileService $importTempFileService = null;
|
|
|
|
|
private ?ImportStateStoreService $importStateStoreService = null;
|
2026-03-13 11:31:33 +01:00
|
|
|
private ?PermissionService $permissionService = null;
|
2026-03-06 00:44:52 +01:00
|
|
|
private ?SettingsDefaultsGateway $settingsDefaultsGateway = null;
|
2026-02-23 12:58:19 +01:00
|
|
|
private ?ImportService $importService = null;
|
2026-03-04 15:56:58 +01:00
|
|
|
|
|
|
|
|
public function __construct(
|
|
|
|
|
private readonly UserServicesFactory $userServicesFactory,
|
|
|
|
|
private readonly AccessServicesFactory $accessServicesFactory,
|
|
|
|
|
private readonly SettingServicesFactory $settingServicesFactory,
|
|
|
|
|
private readonly DirectoryServicesFactory $directoryServicesFactory,
|
refactor(audit): extract audit domain into self-contained module
Move the entire audit subsystem (system audit, API audit, import audit,
user lifecycle audit, frontend telemetry) from core into modules/audit/.
Core decoupling via interface-based injection:
- AuditRecorderInterface replaces SystemAuditService in 10+ core services
- UserLifecycleAuditInterface / ImportAuditInterface for specialized flows
- NullAuditRecorder fallback when audit module is disabled
- ApiBootstrap/ApiResponse use null-safe callable resolvers
Module structure (modules/audit/):
- Manifest with routes, permissions, scheduler jobs, authorization policy
- 9 services, 8 repositories, 6 domain enums, 4 job handlers
- 33 page files, 4 JS files, 8 test files, migration scripts, i18n
Core cleanup:
- OperationsAuthorizationPolicy, UiCapabilityMap, PermissionService
surgically cleaned of audit-specific constants
- Sidebar template cleared of hardcoded audit navigation
- AuditModuleIsolationContractTest ensures no future core→module coupling
All quality gates pass: 1346 tests (19,276 assertions), PHPStan level 5
clean, architecture contracts verified.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-25 21:12:49 +01:00
|
|
|
private readonly ImportAuditInterface $importAudit,
|
2026-03-13 11:31:33 +01:00
|
|
|
private readonly TenantScopeService $tenantScopeService,
|
2026-03-06 00:44:52 +01:00
|
|
|
private readonly SessionStoreInterface $sessionStore
|
2026-03-05 11:17:42 +01:00
|
|
|
) {
|
|
|
|
|
}
|
2026-02-23 12:58:19 +01:00
|
|
|
|
|
|
|
|
public function createImportService(): ImportService
|
|
|
|
|
{
|
|
|
|
|
if ($this->importService !== null) {
|
|
|
|
|
return $this->importService;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$profiles = [
|
2026-03-13 11:31:33 +01:00
|
|
|
'users' => new UserImportProfile(
|
|
|
|
|
new UserImportGateway(
|
|
|
|
|
$this->userServicesFactory->createUserReadRepository(),
|
|
|
|
|
$this->directoryServicesFactory->createTenantRepository(),
|
|
|
|
|
$this->directoryServicesFactory->createRoleRepository(),
|
|
|
|
|
$this->directoryServicesFactory->createDepartmentRepository(),
|
|
|
|
|
),
|
|
|
|
|
$this->userServicesFactory->createUserAccountService()
|
|
|
|
|
),
|
|
|
|
|
'departments' => new DepartmentImportProfile(
|
|
|
|
|
new DepartmentImportGateway(
|
|
|
|
|
$this->directoryServicesFactory->createDepartmentRepository(),
|
|
|
|
|
$this->directoryServicesFactory->createTenantRepository()
|
|
|
|
|
),
|
2026-03-04 15:56:58 +01:00
|
|
|
$this->directoryServicesFactory->createDepartmentService()
|
2026-03-13 11:31:33 +01:00
|
|
|
),
|
2026-02-23 12:58:19 +01:00
|
|
|
];
|
|
|
|
|
|
|
|
|
|
return $this->importService = new ImportService(
|
|
|
|
|
$this->getCsvReaderService(),
|
|
|
|
|
$this->getImportTempFileService(),
|
refactor(audit): extract audit domain into self-contained module
Move the entire audit subsystem (system audit, API audit, import audit,
user lifecycle audit, frontend telemetry) from core into modules/audit/.
Core decoupling via interface-based injection:
- AuditRecorderInterface replaces SystemAuditService in 10+ core services
- UserLifecycleAuditInterface / ImportAuditInterface for specialized flows
- NullAuditRecorder fallback when audit module is disabled
- ApiBootstrap/ApiResponse use null-safe callable resolvers
Module structure (modules/audit/):
- Manifest with routes, permissions, scheduler jobs, authorization policy
- 9 services, 8 repositories, 6 domain enums, 4 job handlers
- 33 page files, 4 JS files, 8 test files, migration scripts, i18n
Core cleanup:
- OperationsAuthorizationPolicy, UiCapabilityMap, PermissionService
surgically cleaned of audit-specific constants
- Sidebar template cleared of hardcoded audit navigation
- AuditModuleIsolationContractTest ensures no future core→module coupling
All quality gates pass: 1346 tests (19,276 assertions), PHPStan level 5
clean, architecture contracts verified.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-25 21:12:49 +01:00
|
|
|
$this->importAudit,
|
2026-02-23 12:58:19 +01:00
|
|
|
$this->createImportStateStoreService(),
|
|
|
|
|
$profiles,
|
2026-03-13 11:31:33 +01:00
|
|
|
$this->createPermissionService(),
|
2026-03-06 00:44:52 +01:00
|
|
|
$this->createSettingsDefaultsGateway(),
|
2026-03-13 11:31:33 +01:00
|
|
|
$this->tenantScopeService,
|
2026-03-06 00:44:52 +01:00
|
|
|
$this->sessionStore
|
2026-02-23 12:58:19 +01:00
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function createImportStateStoreService(): ImportStateStoreService
|
|
|
|
|
{
|
2026-03-06 00:44:52 +01:00
|
|
|
return $this->importStateStoreService ??= new ImportStateStoreService(
|
|
|
|
|
$this->getImportTempFileService(),
|
|
|
|
|
$this->sessionStore
|
|
|
|
|
);
|
2026-02-23 12:58:19 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private function getCsvReaderService(): CsvReaderService
|
|
|
|
|
{
|
|
|
|
|
return $this->csvReaderService ??= new CsvReaderService();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private function getImportTempFileService(): ImportTempFileService
|
|
|
|
|
{
|
|
|
|
|
return $this->importTempFileService ??= new ImportTempFileService();
|
|
|
|
|
}
|
|
|
|
|
|
2026-03-13 11:31:33 +01:00
|
|
|
private function createPermissionService(): PermissionService
|
2026-02-23 12:58:19 +01:00
|
|
|
{
|
2026-03-13 11:31:33 +01:00
|
|
|
return $this->permissionService ??= $this->accessServicesFactory->createPermissionService();
|
2026-02-23 12:58:19 +01:00
|
|
|
}
|
|
|
|
|
|
2026-03-06 00:44:52 +01:00
|
|
|
private function createSettingsDefaultsGateway(): SettingsDefaultsGateway
|
2026-02-23 12:58:19 +01:00
|
|
|
{
|
2026-03-06 00:44:52 +01:00
|
|
|
return $this->settingsDefaultsGateway ??= $this->settingServicesFactory->createSettingsDefaultsGateway();
|
2026-02-23 12:58:19 +01:00
|
|
|
}
|
|
|
|
|
}
|