@@ -27,13 +27,25 @@ class AppServiceProvider extends ServiceProvider
|
||||
$this->app->scoped(AdministrativeGeography::class);
|
||||
$this->app->scoped(StandaloneRuntime::class, fn () => new StandaloneRuntime(config('standalone-runtime'), new StandaloneArtifact));
|
||||
$runtime = $this->app->make(StandaloneRuntime::class);
|
||||
$loader = $runtime;
|
||||
$paths = null;
|
||||
if ($runtime->enabled()) {
|
||||
$preparing = config('standalone-runtime.prepare_only') === true;
|
||||
if ($preparing && (! $this->app->runningInConsole() || $runtime->enabled())) {
|
||||
throw new \LogicException('COMPRAS_RUNTIME_PREPARATION_CONSOLE_ONLY');
|
||||
}
|
||||
if ($runtime->enabled() || $preparing) {
|
||||
if (config('common-finance-bundle.root') !== null || config('budget-distributions.enabled') === true) {
|
||||
throw new \LogicException('COMPRAS_RUNTIME_MIXED_COMPOSITION');
|
||||
}
|
||||
$paths = $runtime->configure(DB::connection());
|
||||
$runtime->assertLoadedPackages(allowMissing: true);
|
||||
if ($preparing) {
|
||||
$settings = config('standalone-runtime');
|
||||
$settings['enabled'] = true;
|
||||
$loader = new StandaloneRuntime($settings, new StandaloneArtifact);
|
||||
$paths = $loader->artifact()['paths'];
|
||||
} else {
|
||||
$paths = $runtime->configure(DB::connection());
|
||||
}
|
||||
$loader->assertLoadedPackages(allowMissing: true);
|
||||
config(['common-budget.path' => $paths['budget-control'], 'common-payables.path' => $paths['payables'],
|
||||
'general-ledger.path' => $paths['general-ledger']]);
|
||||
}
|
||||
@@ -49,7 +61,7 @@ class AppServiceProvider extends ServiceProvider
|
||||
require_once $payables.'/bootstrap.php';
|
||||
if ($paths !== null) {
|
||||
require_once $paths['general-ledger'].'/bootstrap.php';
|
||||
$runtime->assertLoadedPackages();
|
||||
$loader->assertLoadedPackages();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user