2026-02-23 12:58:19 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
namespace MintyPHP\Service\Directory;
|
|
|
|
|
|
2026-03-05 08:26:51 +01:00
|
|
|
use MintyPHP\Repository\Access\RoleRepositoryInterface;
|
|
|
|
|
use MintyPHP\Repository\Org\DepartmentRepositoryInterface;
|
|
|
|
|
use MintyPHP\Repository\Tenant\TenantRepositoryInterface;
|
2026-02-23 12:58:19 +01:00
|
|
|
use MintyPHP\Service\Access\RoleService;
|
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\AuditRecorderInterface;
|
2026-02-23 12:58:19 +01:00
|
|
|
use MintyPHP\Service\Org\DepartmentService;
|
2026-03-13 11:31:33 +01:00
|
|
|
use MintyPHP\Service\Tenant\TenantScopeService;
|
2026-02-23 12:58:19 +01:00
|
|
|
use MintyPHP\Service\Tenant\TenantService;
|
|
|
|
|
use MintyPHP\Service\User\UserServicesFactory;
|
|
|
|
|
|
|
|
|
|
class DirectoryServicesFactory
|
|
|
|
|
{
|
|
|
|
|
private ?TenantService $tenantService = null;
|
|
|
|
|
private ?DepartmentService $departmentService = null;
|
|
|
|
|
private ?RoleService $roleService = null;
|
2026-03-04 15:56:58 +01:00
|
|
|
|
|
|
|
|
public function __construct(
|
|
|
|
|
private readonly UserServicesFactory $userServicesFactory,
|
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 AuditRecorderInterface $auditRecorder,
|
2026-03-04 15:56:58 +01:00
|
|
|
private readonly DirectoryRepositoryFactory $directoryRepositoryFactory,
|
|
|
|
|
private readonly DirectoryGatewayFactory $directoryGatewayFactory
|
2026-03-05 11:17:42 +01:00
|
|
|
) {
|
|
|
|
|
}
|
2026-02-23 12:58:19 +01:00
|
|
|
|
|
|
|
|
public function createTenantService(): TenantService
|
|
|
|
|
{
|
|
|
|
|
return $this->tenantService ??= new TenantService(
|
|
|
|
|
$this->createTenantRepository(),
|
|
|
|
|
$this->createDepartmentRepository(),
|
2026-03-04 15:56:58 +01:00
|
|
|
$this->createDirectorySettingsGateway(),
|
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->auditRecorder
|
2026-02-23 12:58:19 +01:00
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function createDepartmentService(): DepartmentService
|
|
|
|
|
{
|
|
|
|
|
return $this->departmentService ??= new DepartmentService(
|
2026-03-04 15:56:58 +01:00
|
|
|
$this->userServicesFactory,
|
2026-02-23 12:58:19 +01:00
|
|
|
$this->createDepartmentRepository(),
|
|
|
|
|
$this->createDirectorySettingsGateway(),
|
2026-03-13 11:31:33 +01:00
|
|
|
$this->directoryGatewayFactory->getTenantScopeService(),
|
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->auditRecorder
|
2026-02-23 12:58:19 +01:00
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function createRoleService(): RoleService
|
|
|
|
|
{
|
|
|
|
|
return $this->roleService ??= new RoleService(
|
|
|
|
|
$this->createRoleRepository(),
|
2026-03-04 15:56:58 +01:00
|
|
|
$this->createDirectorySettingsGateway(),
|
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->auditRecorder
|
2026-02-23 12:58:19 +01:00
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
2026-03-06 00:44:52 +01:00
|
|
|
// Passthrough accessors so callers only need a reference to this factory, not the sub-factories.
|
2026-03-05 08:26:51 +01:00
|
|
|
public function createTenantRepository(): TenantRepositoryInterface
|
2026-02-23 12:58:19 +01:00
|
|
|
{
|
2026-03-04 15:56:58 +01:00
|
|
|
return $this->directoryRepositoryFactory->createTenantRepository();
|
2026-02-23 12:58:19 +01:00
|
|
|
}
|
|
|
|
|
|
2026-03-05 08:26:51 +01:00
|
|
|
public function createDepartmentRepository(): DepartmentRepositoryInterface
|
2026-02-23 12:58:19 +01:00
|
|
|
{
|
2026-03-04 15:56:58 +01:00
|
|
|
return $this->directoryRepositoryFactory->createDepartmentRepository();
|
2026-02-23 12:58:19 +01:00
|
|
|
}
|
|
|
|
|
|
2026-03-05 08:26:51 +01:00
|
|
|
public function createRoleRepository(): RoleRepositoryInterface
|
2026-02-23 12:58:19 +01:00
|
|
|
{
|
2026-03-04 15:56:58 +01:00
|
|
|
return $this->directoryRepositoryFactory->createRoleRepository();
|
2026-02-23 12:58:19 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function createDirectorySettingsGateway(): DirectorySettingsGateway
|
|
|
|
|
{
|
2026-03-04 15:56:58 +01:00
|
|
|
return $this->directoryGatewayFactory->createDirectorySettingsGateway();
|
2026-02-23 12:58:19 +01:00
|
|
|
}
|
|
|
|
|
|
2026-03-13 11:31:33 +01:00
|
|
|
public function getTenantScopeService(): TenantScopeService
|
2026-02-23 12:58:19 +01:00
|
|
|
{
|
2026-03-13 11:31:33 +01:00
|
|
|
return $this->directoryGatewayFactory->getTenantScopeService();
|
2026-02-23 12:58:19 +01:00
|
|
|
}
|
|
|
|
|
}
|