Files
breadcrumb-the-shire/lib/Service/Tenant/TenantServicesFactory.php
2026-02-23 12:58:19 +01:00

67 lines
2.2 KiB
PHP

<?php
namespace MintyPHP\Service\Tenant;
use MintyPHP\Repository\Org\DepartmentRepository;
use MintyPHP\Repository\Tenant\TenantRepository;
use MintyPHP\Repository\Tenant\UserTenantRepository;
use MintyPHP\Service\Access\AccessServicesFactory;
use MintyPHP\Service\Access\PermissionGateway;
class TenantServicesFactory
{
private ?TenantRepository $tenantRepository = null;
private ?DepartmentRepository $departmentRepository = null;
private ?UserTenantRepository $userTenantRepository = null;
private ?AccessServicesFactory $accessServicesFactory = null;
private ?PermissionGateway $permissionGateway = null;
private ?TenantScopeService $tenantScopeService = null;
private ?TenantAvatarService $tenantAvatarService = null;
private ?TenantFaviconService $tenantFaviconService = null;
public function createTenantScopeService(): TenantScopeService
{
return $this->tenantScopeService ??= new TenantScopeService(
$this->createTenantRepository(),
$this->createDepartmentRepository(),
$this->createUserTenantRepository(),
$this->createPermissionGateway()
);
}
public function createTenantAvatarService(): TenantAvatarService
{
return $this->tenantAvatarService ??= new TenantAvatarService();
}
public function createTenantFaviconService(): TenantFaviconService
{
return $this->tenantFaviconService ??= new TenantFaviconService();
}
public function createTenantRepository(): TenantRepository
{
return $this->tenantRepository ??= new TenantRepository();
}
public function createDepartmentRepository(): DepartmentRepository
{
return $this->departmentRepository ??= new DepartmentRepository();
}
public function createUserTenantRepository(): UserTenantRepository
{
return $this->userTenantRepository ??= new UserTenantRepository();
}
public function createPermissionGateway(): PermissionGateway
{
return $this->permissionGateway ??= $this->accessServicesFactory()->createPermissionGateway();
}
private function accessServicesFactory(): AccessServicesFactory
{
return $this->accessServicesFactory ??= new AccessServicesFactory();
}
}