Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 23 additions & 16 deletions system/ioc/dsl/ColdBoxDSL.cfc
Original file line number Diff line number Diff line change
Expand Up @@ -175,27 +175,34 @@ component accessors="true" {
// module setting?
if ( find( "@", thisLocationKey ) ) {
moduleSettings = variables.coldbox.getSetting( "modules" );
if (
structKeyExists( moduleSettings, listLast( thisLocationKey, "@" ) )
and structKeyExists(
moduleSettings[ listLast( thisLocationKey, "@" ) ],
"settings"
)
and structKeyExists(
moduleSettings[ listLast( thisLocationKey, "@" ) ].settings,
listFirst( thisLocationKey, "@" )
)
) {
return moduleSettings[ listLast( thisLocationKey, "@" ) ].settings[
listFirst( thisLocationKey, "@" )
];
} else {
var moduleName = listLast( thisLocationKey, "@" );
if ( !structKeyExists( moduleSettings, moduleName ) ) {
throw(
type = "ColdBoxDSL.InvalidDSL",
message = "The DSL provided was not valid: #arguments.definition.toString()#",
detail = "The module requested: #moduleName# does not exist in the loaded modules. Loaded modules are #structKeyList( moduleSettings )#"
);
}

if ( !structKeyExists( moduleSettings[ moduleName ], "settings" ) ) {
throw(
type = "ColdBoxDSL.InvalidDSL",
message = "The DSL provided was not valid: #arguments.definition.toString()#",
detail = "The module requested: #listLast( thisLocationKey, "@" )# does not exist in the loaded modules. Loaded modules are #structKeyList( moduleSettings )#"
detail = "The module requested: #moduleName# does not have any settings defined."
);
}

var settingName = listFirst( thisLocationKey, "@" )

if ( !structKeyExists( moduleSettings[ moduleName ].settings, settingName ) ) {
throw(
type = "ColdBoxDSL.InvalidDSL",
message = "The DSL provided was not valid: #arguments.definition.toString()#",
detail = "The module requested: #moduleName# does not have the setting [#settingName#] defined. Available settings are: [#moduleSettings[ moduleName ].settings.keyList( ", " )#]"
);
}

return moduleSettings[ moduleName ].settings[ settingName ];
}
// just get setting
return variables.coldbox.getSetting( thisLocationKey );
Expand Down
8 changes: 4 additions & 4 deletions tests/specs/ioc/dsl/ColdBoxDSLTest.cfc
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<cfcomponent extends="coldbox.system.testing.BaseModelTest">
<cfscript>
component extends="coldbox.system.testing.BaseModelTest" {

function setup(){
mockLogger = createEmptyMock( "coldbox.system.logging.Logger" )
.$( "canDebug", true )
Expand Down Expand Up @@ -184,5 +184,5 @@
c = builder.getColdBoxDSL( def );
assertEquals( this, c );
}
</cfscript>
</cfcomponent>

}
Loading