function configuration_execute in Configuration Management 6
Execute a configuration diven a data object of actions. The supplied data should be a php array in the correct format.
Here is an example configuration to setup two blocks:
array( array( tag => block config => array( description => My Custom Block region => right weight => -5 ) ) array( tag => block config => array( id => locale-0 region => left weight => 5 ) ) )
Parameters
$data: The dataset containing the configuration to execute
$mode: A string that will form a callback function used to dictate execution of the configuration. Two default modes are:
- batch: Run the configuration on a batch/progress bar page
- xmlrpc: Run the configuration through services without a break in the pages php execution
The job of the callback function is to ensure that data set in the configuration_set_data static cache is maintained through any possible page re-loads or however the execution is processed so that each pass of configuration_execute_pass has the right data available to it.
Return value
TRUE or FALSE for successful execution. The exact error in case of an unsuccessful run can be retrieved with configuration_get_error()
File
- ./
configuration.module, line 109 - Provide a unified method for defining site configurations abstracted from their data format. Various data formats should be supported via a plugin architecture such as XML, YAML, JSON, PHP
Code
function configuration_execute($data, $mode = 'batch', $current_id = null) {
$args = func_get_args();
array_splice($args, 0, 3);
$function = 'configuration_execute_' . $mode;
if (!function_exists($function)) {
return FALSE;
}
// Create and set a unique id for this execution
if (!$current_id) {
$current_id = md5(mt_rand());
}
configuration_set_current_id($current_id);
// Set the current data so it can be used with this execution
configuration_set_data('data', $data);
// Set to the first phase to get things started
configuration_set_data('phase', CONFIGURATION_INTIALIZE);
return call_user_func_array($function, $args);
}