Skip to content

Instantly share code, notes, and snippets.

@jsteinshouer
Created July 13, 2016 17:48
Embed
What would you like to do?
Load custom config setting from JSON file
void function afterConfigurationLoad(event,interceptData,buffer){
//writeDump(controller.getConfigSettings())
var basePath = getDirectoryFromPath(getCurrentTemplatePath());
/* Check for custom configuration file. This should be ignrored */
if (fileExists("#basePath#/CustomConfig.json.cfm")) {
var settingsJSON = fileRead("#basePath#/CustomConfig.json.cfm");
/* File should be valid json */
if (isJSON(settingsJSON)) {
var customSettings = deserializeJSON(settingsJSON);
/* Append/overrite current settings */
for (var key in customSettings) {
controller.setSetting(key, customSettings[key]);
//log.info("Added environment secret #key# to settings");
}
}
}
//writeDump(controller.getConfigSettings());abort;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment