refactor(arch): enforce gateway compliance and remove service-wrapping gateways
This commit is contained in:
@@ -5,7 +5,7 @@ namespace MintyPHP\Service\Import;
|
||||
use MintyPHP\Http\SessionStoreInterface;
|
||||
use MintyPHP\Repository\Audit\ImportAuditRunRepositoryInterface;
|
||||
use MintyPHP\Service\Access\AccessServicesFactory;
|
||||
use MintyPHP\Service\Access\PermissionGateway;
|
||||
use MintyPHP\Service\Access\PermissionService;
|
||||
use MintyPHP\Service\Audit\ImportAuditService;
|
||||
use MintyPHP\Service\Directory\DirectoryServicesFactory;
|
||||
use MintyPHP\Service\Import\Profile\DepartmentImportGateway;
|
||||
@@ -14,6 +14,7 @@ use MintyPHP\Service\Import\Profile\UserImportGateway;
|
||||
use MintyPHP\Service\Import\Profile\UserImportProfile;
|
||||
use MintyPHP\Service\Settings\SettingsDefaultsGateway;
|
||||
use MintyPHP\Service\Settings\SettingServicesFactory;
|
||||
use MintyPHP\Service\Tenant\TenantScopeService;
|
||||
use MintyPHP\Service\User\UserServicesFactory;
|
||||
|
||||
class ImportServicesFactory
|
||||
@@ -22,7 +23,7 @@ class ImportServicesFactory
|
||||
private ?ImportTempFileService $importTempFileService = null;
|
||||
private ?ImportStateStoreService $importStateStoreService = null;
|
||||
private ?ImportAuditService $importAuditService = null;
|
||||
private ?PermissionGateway $permissionGateway = null;
|
||||
private ?PermissionService $permissionService = null;
|
||||
private ?SettingsDefaultsGateway $settingsDefaultsGateway = null;
|
||||
private ?ImportService $importService = null;
|
||||
|
||||
@@ -32,6 +33,7 @@ class ImportServicesFactory
|
||||
private readonly SettingServicesFactory $settingServicesFactory,
|
||||
private readonly DirectoryServicesFactory $directoryServicesFactory,
|
||||
private readonly ImportRepositoryFactory $importRepositoryFactory,
|
||||
private readonly TenantScopeService $tenantScopeService,
|
||||
private readonly SessionStoreInterface $sessionStore
|
||||
) {
|
||||
}
|
||||
@@ -43,18 +45,22 @@ class ImportServicesFactory
|
||||
}
|
||||
|
||||
$profiles = [
|
||||
'users' => new UserImportProfile(new UserImportGateway(
|
||||
$this->userServicesFactory->createUserReadRepository(),
|
||||
$this->userServicesFactory->createUserAccountService(),
|
||||
$this->directoryServicesFactory->createTenantRepository(),
|
||||
$this->directoryServicesFactory->createRoleRepository(),
|
||||
$this->directoryServicesFactory->createDepartmentRepository(),
|
||||
)),
|
||||
'departments' => new DepartmentImportProfile(new DepartmentImportGateway(
|
||||
$this->directoryServicesFactory->createDepartmentRepository(),
|
||||
$this->directoryServicesFactory->createTenantRepository(),
|
||||
'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()
|
||||
),
|
||||
$this->directoryServicesFactory->createDepartmentService()
|
||||
)),
|
||||
),
|
||||
];
|
||||
|
||||
return $this->importService = new ImportService(
|
||||
@@ -63,9 +69,9 @@ class ImportServicesFactory
|
||||
$this->createImportAuditService(),
|
||||
$this->createImportStateStoreService(),
|
||||
$profiles,
|
||||
$this->createPermissionGateway(),
|
||||
$this->createPermissionService(),
|
||||
$this->createSettingsDefaultsGateway(),
|
||||
$this->userServicesFactory->createUserScopeGateway(),
|
||||
$this->tenantScopeService,
|
||||
$this->sessionStore
|
||||
);
|
||||
}
|
||||
@@ -98,9 +104,9 @@ class ImportServicesFactory
|
||||
return $this->importRepositoryFactory->createImportAuditRunRepository();
|
||||
}
|
||||
|
||||
private function createPermissionGateway(): PermissionGateway
|
||||
private function createPermissionService(): PermissionService
|
||||
{
|
||||
return $this->permissionGateway ??= $this->accessServicesFactory->createPermissionGateway();
|
||||
return $this->permissionService ??= $this->accessServicesFactory->createPermissionService();
|
||||
}
|
||||
|
||||
private function createSettingsDefaultsGateway(): SettingsDefaultsGateway
|
||||
|
||||
Reference in New Issue
Block a user