Skip to content

Instantly share code, notes, and snippets.

@jsteinshouer
Created July 13, 2016 17:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jsteinshouer/914207142366cdcae056d4199e879afe to your computer and use it in GitHub Desktop.
Save jsteinshouer/914207142366cdcae056d4199e879afe to your computer and use it in GitHub Desktop.
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