asdasd
This commit is contained in:
42
custom/apps/fx-rates/bootstrap.php
Normal file
42
custom/apps/fx-rates/bootstrap.php
Normal file
@@ -0,0 +1,42 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
spl_autoload_register(static function (string $class): void {
|
||||
$prefix = 'Modules\\FxRates\\';
|
||||
if (!str_starts_with($class, $prefix)) {
|
||||
return;
|
||||
}
|
||||
|
||||
$relative = substr($class, strlen($prefix));
|
||||
$path = __DIR__ . '/src/' . str_replace('\\', '/', $relative) . '.php';
|
||||
if (is_file($path)) {
|
||||
require_once $path;
|
||||
}
|
||||
});
|
||||
|
||||
$moduleName = 'fx-rates';
|
||||
$moduleBasePath = __DIR__;
|
||||
|
||||
if (method_exists(modules(), 'registerFunction')) {
|
||||
modules()->registerFunction($moduleName, 'service', static function () use ($moduleBasePath): \Modules\FxRates\Domain\FxRatesService {
|
||||
static $service = null;
|
||||
|
||||
if ($service instanceof \Modules\FxRates\Domain\FxRatesService) {
|
||||
return $service;
|
||||
}
|
||||
|
||||
$moduleConfig = \Modules\FxRates\Infrastructure\ModuleConfig::load($moduleBasePath);
|
||||
$settingsStore = new \Modules\FxRates\Infrastructure\SettingsStore($moduleConfig);
|
||||
$settings = $settingsStore->load();
|
||||
$pdo = \Modules\FxRates\Infrastructure\ConnectionFactory::make($settingsStore);
|
||||
$repository = new \Modules\FxRates\Infrastructure\FxRatesRepository(
|
||||
$pdo,
|
||||
$moduleConfig->tablePrefix()
|
||||
);
|
||||
$repository->ensureSchema();
|
||||
|
||||
$service = new \Modules\FxRates\Domain\FxRatesService($repository, $settings);
|
||||
|
||||
return $service;
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user