Files
breadcrumb-the-shire/lib/Service/Tenant/TenantServicesFactory.php

62 lines
1.9 KiB
PHP
Raw Normal View History

2026-02-23 12:58:19 +01:00
<?php
namespace MintyPHP\Service\Tenant;
2026-03-05 08:26:51 +01:00
use MintyPHP\Repository\Org\DepartmentRepositoryInterface;
use MintyPHP\Repository\Tenant\TenantRepositoryInterface;
use MintyPHP\Repository\Tenant\UserTenantRepositoryInterface;
use MintyPHP\Service\Access\PermissionService;
2026-02-23 12:58:19 +01:00
class TenantServicesFactory
{
private ?TenantScopeService $tenantScopeService = null;
private ?TenantAvatarService $tenantAvatarService = null;
private ?TenantFaviconService $tenantFaviconService = null;
2026-03-04 15:56:58 +01:00
public function __construct(
private readonly PermissionService $permissionService,
2026-03-04 15:56:58 +01:00
private readonly TenantRepositoryFactory $tenantRepositoryFactory
2026-03-05 11:17:42 +01:00
) {
}
2026-03-04 15:56:58 +01:00
2026-02-23 12:58:19 +01:00
public function createTenantScopeService(): TenantScopeService
{
return $this->tenantScopeService ??= new TenantScopeService(
$this->createTenantRepository(),
$this->createDepartmentRepository(),
$this->createUserTenantRepository(),
$this->createPermissionService()
2026-02-23 12:58:19 +01:00
);
}
public function createTenantAvatarService(): TenantAvatarService
{
return $this->tenantAvatarService ??= new TenantAvatarService();
}
public function createTenantFaviconService(): TenantFaviconService
{
return $this->tenantFaviconService ??= new TenantFaviconService();
}
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->tenantRepositoryFactory->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->tenantRepositoryFactory->createDepartmentRepository();
2026-02-23 12:58:19 +01:00
}
2026-03-05 08:26:51 +01:00
public function createUserTenantRepository(): UserTenantRepositoryInterface
2026-02-23 12:58:19 +01:00
{
2026-03-04 15:56:58 +01:00
return $this->tenantRepositoryFactory->createUserTenantRepository();
2026-02-23 12:58:19 +01:00
}
public function createPermissionService(): PermissionService
2026-02-23 12:58:19 +01:00
{
return $this->permissionService;
2026-02-23 12:58:19 +01:00
}
}