[Coldbox 7] How to Override Module Config Objects Per Environment?

Back in the Coldbox 6 days, if we wanted to override a module’s settings for a particular environment, we could do so in the /config/coldbox.cfc file like this:

function configure() {
  // ... coldbox config

  // module config
  modulesettings {
    moduleName: {
      setting: "foo"
    }
  }

// development overrides in coldbox.cfc
function development() {
    modulesettings.modulename.setting = "bar";
}

Now that we are rocking Coldbox 7, we can break module settings into a separate file like this:

// config/modules/modulename.cfc
function configure() {
  return {
    setting: "foo"
  };
}

How do we implement the override for the development environment using this new approach? Adding a development() method to the new module config file doesn’t seem to work as I would expect.

// development overrides in config/modules/modulename.cfc
function development() {
    modulesettings.modulename.setting = "bar"; // <-- does not work!
}

Is there a different scope we need to use to reference the module settings?

You need to pass in the module config struct like so:

function development( original ){
    original.setting = "bar"; 
}
1 Like

You saved the day, @Andrew_Kretzer! Thank you!

1 Like