Using Configurator


Overview

The Configurator is a class used to manage the config settings found in ‘config.php’ and ‘config_override.php’.

The Configurator Class

The Configurator class is located in ‘modules/Configurator/Configurator.php’. Settings modified using this class are written to ‘config_override.php’ which is stored in the root directory of your SugarCRM installation.

Retrieving Settings

You can access the SugarCRM config settings by using the global variable ‘sugar_config’ as shown below:
global $sugar_config;
//Use a specific setting
$MySetting = $sugar_config['MySetting'];
If you should need to reload the config settings, this is an example of how to retrieve a specific setting using the configurator:
require_once 'modules/Configurator/Configurator.php';
$configuratorObj = new Configurator();
//Load config
$configuratorObj->loadConfig();
//Use a specific setting
$MySetting = $configuratorObj->config['MySetting'];

Creating / Updating Settings

To create or update a specific setting, you can specify the new value using the configurator as shown below:
require_once 'modules/Configurator/Configurator.php';
$configuratorObj = new Configurator();
//Load config
$configuratorObj->loadConfig();
//Update a specific setting
$configuratorObj->config['MySetting'] = "MySettingsValue";
//Save the new setting
$configuratorObj->saveConfig();

Considerations

When looking to store custom settings, the Configurator class will store the settings in the ‘config_override.php’ file. Alternatively, you can use the Administration class located in ./modules/Administration/Administration.php to store the settings in the ‘config’ table in the database.