asdfsad
All checks were successful
Deploy / deploy-staging (push) Successful in 24s
Deploy / deploy-production (push) Has been skipped

This commit is contained in:
2026-06-22 01:47:21 +02:00
parent f9e41380b5
commit cfcb37ca7e
2 changed files with 124 additions and 17 deletions

View File

@@ -3,6 +3,11 @@ declare(strict_types=1);
namespace Modules\MiningChecker\Domain;
use Modules\FxRates\Domain\FxRatesService as SharedFxRatesService;
use Modules\FxRates\Infrastructure\ConnectionFactory as SharedFxConnectionFactory;
use Modules\FxRates\Infrastructure\FxRatesRepository as SharedFxRatesRepository;
use Modules\FxRates\Infrastructure\ModuleConfig as SharedFxModuleConfig;
use Modules\FxRates\Infrastructure\SettingsStore as SharedFxSettingsStore;
use Modules\MiningChecker\Infrastructure\MiningRepository;
use Modules\MiningChecker\Support\DebugTrace;
@@ -19,6 +24,8 @@ final class FxService
private array $memoryCache = [];
private array $snapshotCache = [];
private ?DebugTrace $debug;
private bool $sharedServiceResolved = false;
private ?object $sharedService = null;
public function __construct(
?MiningRepository $repository = null,
@@ -893,15 +900,38 @@ final class FxService
private function sharedFxService(): ?object
{
if (!function_exists('modules') || !modules()->isEnabled('fx-rates') || !modules()->hasFunction('fx-rates', 'service')) {
return null;
if ($this->sharedServiceResolved) {
return $this->sharedService;
}
try {
$service = module_fn('fx-rates', 'service');
return is_object($service) ? $service : null;
$moduleBasePath = dirname(__DIR__, 2) . '/../fx-rates';
$bootstrap = $moduleBasePath . '/bootstrap.php';
if (!is_file($bootstrap)) {
$this->sharedServiceResolved = true;
return $this->sharedService = null;
}
require_once $bootstrap;
if (!class_exists(SharedFxModuleConfig::class) || !class_exists(SharedFxRatesService::class)) {
$this->sharedServiceResolved = true;
return $this->sharedService = null;
}
$config = SharedFxModuleConfig::load($moduleBasePath);
$settingsStore = new SharedFxSettingsStore($config);
$repository = new SharedFxRatesRepository(
SharedFxConnectionFactory::make($settingsStore),
$config->tablePrefix()
);
$repository->ensureSchema();
$this->sharedServiceResolved = true;
return $this->sharedService = new SharedFxRatesService($repository, $settingsStore->load());
} catch (\Throwable) {
return null;
$this->sharedServiceResolved = true;
return $this->sharedService = null;
}
}