forked from fa/breadcrumb-the-shire
62 lines
1.9 KiB
PHP
62 lines
1.9 KiB
PHP
<?php
|
|
|
|
namespace MintyPHP\Service\Tenant;
|
|
|
|
use MintyPHP\Repository\Org\DepartmentRepositoryInterface;
|
|
use MintyPHP\Repository\Tenant\TenantRepositoryInterface;
|
|
use MintyPHP\Repository\Tenant\UserTenantRepositoryInterface;
|
|
use MintyPHP\Service\Access\PermissionGateway;
|
|
|
|
class TenantServicesFactory
|
|
{
|
|
private ?TenantScopeService $tenantScopeService = null;
|
|
private ?TenantAvatarService $tenantAvatarService = null;
|
|
private ?TenantFaviconService $tenantFaviconService = null;
|
|
|
|
public function __construct(
|
|
private readonly PermissionGateway $permissionGateway,
|
|
private readonly TenantRepositoryFactory $tenantRepositoryFactory
|
|
) {
|
|
}
|
|
|
|
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(): TenantRepositoryInterface
|
|
{
|
|
return $this->tenantRepositoryFactory->createTenantRepository();
|
|
}
|
|
|
|
public function createDepartmentRepository(): DepartmentRepositoryInterface
|
|
{
|
|
return $this->tenantRepositoryFactory->createDepartmentRepository();
|
|
}
|
|
|
|
public function createUserTenantRepository(): UserTenantRepositoryInterface
|
|
{
|
|
return $this->tenantRepositoryFactory->createUserTenantRepository();
|
|
}
|
|
|
|
public function createPermissionGateway(): PermissionGateway
|
|
{
|
|
return $this->permissionGateway;
|
|
}
|
|
}
|