Files
breadcrumb-the-shire/lib/Service/Directory/DirectoryServicesFactory.php
2026-03-05 08:26:51 +01:00

82 lines
2.8 KiB
PHP

<?php
namespace MintyPHP\Service\Directory;
use MintyPHP\Repository\Access\RoleRepositoryInterface;
use MintyPHP\Repository\Org\DepartmentRepositoryInterface;
use MintyPHP\Repository\Tenant\TenantRepositoryInterface;
use MintyPHP\Service\Access\RoleService;
use MintyPHP\Service\Audit\AuditServicesFactory;
use MintyPHP\Service\Org\DepartmentService;
use MintyPHP\Service\Tenant\TenantService;
use MintyPHP\Service\User\UserServicesFactory;
class DirectoryServicesFactory
{
private ?TenantService $tenantService = null;
private ?DepartmentService $departmentService = null;
private ?RoleService $roleService = null;
public function __construct(
private readonly UserServicesFactory $userServicesFactory,
private readonly AuditServicesFactory $auditServicesFactory,
private readonly DirectoryRepositoryFactory $directoryRepositoryFactory,
private readonly DirectoryGatewayFactory $directoryGatewayFactory
) {}
public function createTenantService(): TenantService
{
return $this->tenantService ??= new TenantService(
$this->createTenantRepository(),
$this->createDepartmentRepository(),
$this->createDirectorySettingsGateway(),
$this->auditServicesFactory->createSystemAuditService()
);
}
public function createDepartmentService(): DepartmentService
{
return $this->departmentService ??= new DepartmentService(
$this->userServicesFactory,
$this->createDepartmentRepository(),
$this->createDirectorySettingsGateway(),
$this->createDirectoryScopeGateway(),
$this->auditServicesFactory->createSystemAuditService()
);
}
public function createRoleService(): RoleService
{
return $this->roleService ??= new RoleService(
$this->createRoleRepository(),
$this->createDirectorySettingsGateway(),
$this->auditServicesFactory->createSystemAuditService()
);
}
public function createTenantRepository(): TenantRepositoryInterface
{
return $this->directoryRepositoryFactory->createTenantRepository();
}
public function createDepartmentRepository(): DepartmentRepositoryInterface
{
return $this->directoryRepositoryFactory->createDepartmentRepository();
}
public function createRoleRepository(): RoleRepositoryInterface
{
return $this->directoryRepositoryFactory->createRoleRepository();
}
public function createDirectorySettingsGateway(): DirectorySettingsGateway
{
return $this->directoryGatewayFactory->createDirectorySettingsGateway();
}
public function createDirectoryScopeGateway(): DirectoryScopeGateway
{
return $this->directoryGatewayFactory->createDirectoryScopeGateway();
}
}