function configuration_run_pass in Configuration Management 6
Run through a pass of the configuration process
Return value
Return the current phase
1 call to configuration_run_pass()
- _configuration_execute_batch in ./
configuration.module - Batch callback function for batch execution
File
- ./
configuration.module, line 141 - 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_run_pass() {
$phases = array(
CONFIGURATION_INTIALIZE,
CONFIGURATION_DEFAULT_MAP,
CONFIGURATION_ENABLE_MODULES,
CONFIGURATION_MODULE_MAPS,
CONFIGURATION_EXECUTE_ACTIONS,
CONFIGURATION_DISABLE_MODULES,
CONFIGURATION_FINALIZE,
);
$phase =& configuration_get_data('phase');
$context =& configuration_get_data('context');
$data =& configuration_get_data('data');
// The context object is required for every phase except the first
// Also, the original data object should always be a reference to the
// data in the context object which we can't guarantee unless we do it
// ourselves here.
if (is_object($context)) {
$data =& $context->item;
}
else {
if ($phase > CONFIGURATION_INTIALIZE) {
configuration_set_error('no_context');
$phase = CONFIGURATION_ERROR;
}
}
// Ensure our phase is valid
if (!in_array($phase, $phases)) {
configuration_set_error('invalid_phase', array(
'phase' => $phase,
));
}
// Make sure necessary include files are loaded
configuration_load_includes();
switch ($phase) {
// TODO Decide if maybe we should run the first few phases all at once
case CONFIGURATION_INTIALIZE:
configuration_initiate();
$phase++;
break;
case CONFIGURATION_DEFAULT_MAP:
// First apply the base configuration map. This primary purpose
// of this map is to set appropriate attributes in the context
// object, make it look a bit nicer, and build the module list
configuration_apply_map($context, configuration_default_map());
if (!configuration_get_error()) {
$phase++;
}
break;
case CONFIGURATION_ENABLE_MODULES:
// Enable all modules set in the configuration
$modules =& configuration_get_data('enable modules');
if (!empty($modules)) {
configuration_enable_modules($modules);
}
if (!configuration_get_error()) {
$phase++;
}
break;
case CONFIGURATION_MODULE_MAPS:
// Apply all module configuration maps to the object to prepare
// the data, apply some basic validations, and setup data needed
// for the next configuration phases
configuration_apply_maps($context);
if (!configuration_get_error()) {
$phase++;
}
break;
case CONFIGURATION_EXECUTE_ACTIONS:
// Go through the built list of actions and build/run them one at a time
configuration_process_actions();
$left = count(configuration_get_data('actions'));
if ($phase != CONFIGURATION_ERROR && !$left) {
$phase++;
}
break;
case CONFIGURATION_DISABLE_MODULES:
// Disable modules
$modules =& configuration_get_data('disable modules');
if (!empty($modules)) {
configuration_disable_modules($modules);
}
if (!configuration_get_error()) {
$phase++;
}
break;
case CONFIGURATION_FINALIZE:
// The configuration succeed so do any necessary cleanup
configuration_finalize();
$phases++;
break;
case CONFIGURATION_SUCCESS:
// We are done. Nothing to do here.
break;
case CONFIGURATION_ERROR:
default:
// TODO Error handling
break;
}
// Any data can be retreived through configuration_get_data, but this can be
// a quick way of determining if there was an error
return $phase;
}