Skip to content

Commit

Permalink
Change "base" configurator, set the configuration items
Browse files Browse the repository at this point in the history
By extending the bound configuration repository, whenever it is resolved, the resulting repository will be populated with the items specified in the application configurator.
  • Loading branch information
aedart committed Oct 3, 2024
1 parent f712c07 commit 7ef6b0a
Showing 1 changed file with 22 additions and 3 deletions.
25 changes: 22 additions & 3 deletions packages/core/src/configuration/BaseConfigurator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,15 @@ import type {
ServiceProvider,
ServiceProviderConstructor
} from "@aedart/contracts/support/services";
import { AbstractClassError } from "@aedart/support/exceptions";
import { isset } from "@aedart/support/misc";
import {
import type {
BindingTuple,
IdentifierAliasTuple,
IdentifierInstanceTuple
} from "@aedart/contracts/container";
import type { Repository } from "@aedart/contracts/config";
import { CONFIG } from "@aedart/contracts/config";
import { AbstractClassError } from "@aedart/support/exceptions";
import { isset } from "@aedart/support/misc";
import { shallowMerge } from "@aedart/support/objects";
import ConfigurationError from "../exceptions/ConfigurationError";

Expand Down Expand Up @@ -249,6 +251,7 @@ export default abstract class BaseConfigurator implements Configurator {
.registerBindings()
.registerAliases()
.registerBootstrappers()
.setConfigurationItems()
.registerServiceProviders();

this.after(this.app as Application);
Expand Down Expand Up @@ -358,6 +361,22 @@ export default abstract class BaseConfigurator implements Configurator {
return this;
}

/**
* Set the items in the application's [Configuration Repository]{@link import('@aedart/contracts/config').Repository}
*
* @return {this}
*
* @protected
*/
protected setConfigurationItems(): this
{
this.app?.extend(CONFIG, (resolved: Repository) => {
return resolved.merge(this.configurationItems);
});

return this;
}

/**
* Register "core" service providers
*
Expand Down

0 comments on commit 7ef6b0a

Please sign in to comment.