Files
breadcrumb-the-shire/lib/Service/Settings/SettingServicesFactory.php

68 lines
2.1 KiB
PHP
Raw Normal View History

2026-02-23 12:58:19 +01:00
<?php
namespace MintyPHP\Service\Settings;
2026-03-05 08:26:51 +01:00
use MintyPHP\Repository\Access\RoleRepositoryInterface;
use MintyPHP\Repository\Org\DepartmentRepositoryInterface;
use MintyPHP\Repository\Settings\SettingRepositoryInterface;
use MintyPHP\Repository\Tenant\TenantRepositoryInterface;
2026-02-23 12:58:19 +01:00
class SettingServicesFactory
{
private ?ThemeConfigService $themeConfigService = null;
private ?SettingService $settingService = null;
private ?SettingCacheService $settingCacheService = null;
private ?SettingGateway $settingGateway = null;
2026-03-04 15:56:58 +01:00
public function __construct(
private readonly SettingRepositoryFactory $settingRepositoryFactory
2026-03-05 11:17:42 +01:00
) {
}
2026-03-04 15:56:58 +01:00
2026-03-05 08:26:51 +01:00
public function createSettingRepository(): SettingRepositoryInterface
2026-02-23 12:58:19 +01:00
{
2026-03-04 15:56:58 +01:00
return $this->settingRepositoryFactory->createSettingRepository();
2026-02-23 12:58:19 +01:00
}
public function createSettingService(): SettingService
{
return $this->settingService ??= new SettingService(
$this->createSettingRepository(),
$this->createTenantRepository(),
$this->createRoleRepository(),
$this->createDepartmentRepository(),
$this->createThemeConfigService()
);
}
public function createSettingGateway(): SettingGateway
{
return $this->settingGateway ??= new SettingGateway($this->createSettingService());
}
public function createSettingCacheService(): SettingCacheService
{
return $this->settingCacheService ??= new SettingCacheService();
}
public function createThemeConfigService(): ThemeConfigService
{
return $this->themeConfigService ??= new ThemeConfigService();
}
2026-03-05 08:26:51 +01:00
private function createTenantRepository(): TenantRepositoryInterface
2026-02-23 12:58:19 +01:00
{
2026-03-04 15:56:58 +01:00
return $this->settingRepositoryFactory->createTenantRepository();
2026-02-23 12:58:19 +01:00
}
2026-03-05 08:26:51 +01:00
private function createRoleRepository(): RoleRepositoryInterface
2026-02-23 12:58:19 +01:00
{
2026-03-04 15:56:58 +01:00
return $this->settingRepositoryFactory->createRoleRepository();
2026-02-23 12:58:19 +01:00
}
2026-03-05 08:26:51 +01:00
private function createDepartmentRepository(): DepartmentRepositoryInterface
2026-02-23 12:58:19 +01:00
{
2026-03-04 15:56:58 +01:00
return $this->settingRepositoryFactory->createDepartmentRepository();
2026-02-23 12:58:19 +01:00
}
}