68 lines
2.1 KiB
PHP
68 lines
2.1 KiB
PHP
<?php
|
|
|
|
namespace MintyPHP\Service\Settings;
|
|
|
|
use MintyPHP\Repository\Access\RoleRepositoryInterface;
|
|
use MintyPHP\Repository\Org\DepartmentRepositoryInterface;
|
|
use MintyPHP\Repository\Settings\SettingRepositoryInterface;
|
|
use MintyPHP\Repository\Tenant\TenantRepositoryInterface;
|
|
|
|
class SettingServicesFactory
|
|
{
|
|
private ?ThemeConfigService $themeConfigService = null;
|
|
private ?SettingService $settingService = null;
|
|
private ?SettingCacheService $settingCacheService = null;
|
|
private ?SettingGateway $settingGateway = null;
|
|
|
|
public function __construct(
|
|
private readonly SettingRepositoryFactory $settingRepositoryFactory
|
|
) {
|
|
}
|
|
|
|
public function createSettingRepository(): SettingRepositoryInterface
|
|
{
|
|
return $this->settingRepositoryFactory->createSettingRepository();
|
|
}
|
|
|
|
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();
|
|
}
|
|
|
|
private function createTenantRepository(): TenantRepositoryInterface
|
|
{
|
|
return $this->settingRepositoryFactory->createTenantRepository();
|
|
}
|
|
|
|
private function createRoleRepository(): RoleRepositoryInterface
|
|
{
|
|
return $this->settingRepositoryFactory->createRoleRepository();
|
|
}
|
|
|
|
private function createDepartmentRepository(): DepartmentRepositoryInterface
|
|
{
|
|
return $this->settingRepositoryFactory->createDepartmentRepository();
|
|
}
|
|
}
|