function coder_upgrade_start in Coder 7
Same name and namespace in other branches
- 7.2 coder_upgrade/includes/main.inc \coder_upgrade_start()
Prepares conversion environment and starts conversion loop.
Parameters
array $upgrades: Array of upgrade sets to apply.
array $extensions: Array of file types to convert based on extension.
array $items: Array of directories containing the files to convert.
boolean $recursive: Indicates whether to recurse the subdirectories of each $item.
Return value
boolean Indicates whether the conversion code was successfully applied.
3 calls to coder_upgrade_start()
- CoderUpgradeUnitTestCase::testRunInterface in coder_upgrade/
coder_upgrade.test - Tests the upgrade routines (outside of the user interface).
- coder_upgrade.run.php in coder_upgrade/
scripts/ coder_upgrade.run.php - coder_upgrade_conversions_apply in coder_upgrade/
includes/ conversion.inc - Applies the module conversion code.
File
- coder_upgrade/
includes/ main.inc, line 28 - Manages application of conversion routines, logging, and patch file creation.
Code
function coder_upgrade_start($upgrades, $extensions, $items, $recursive = TRUE) {
// Declare global variables.
global $_coder_upgrade_log, $_coder_upgrade_debug, $_coder_upgrade_module_name, $_coder_upgrade_replace_files, $_coder_upgrade_class_files;
// global $_coder_upgrade_dirname; // Not used.
// Check lists in case this function is called apart from form submit.
if (!is_array($upgrades) || empty($upgrades)) {
return FALSE;
}
if (!is_array($extensions) || empty($extensions)) {
return FALSE;
}
if (!is_array($items) || empty($items)) {
return FALSE;
}
$_coder_upgrade_log = TRUE;
if ($_coder_upgrade_log) {
// Clear the log file.
coder_upgrade_path_clear('log');
if (!variable_get('coder_upgrade_use_separate_process', FALSE)) {
coder_upgrade_path_clear('memory');
}
coder_upgrade_memory_print('initial');
}
// Set debug output preference.
$_coder_upgrade_debug = variable_get('coder_upgrade_enable_debug_output', FALSE);
if ($_coder_upgrade_debug) {
// Clear the debug file.
coder_upgrade_path_clear('debug');
}
// Load code.
coder_upgrade_load_code($upgrades);
coder_upgrade_load_parser();
// Set file replacement parameter.
$_coder_upgrade_replace_files = variable_get('coder_upgrade_replace_files', FALSE);
// Initialize list of class files.
$_coder_upgrade_class_files = array();
// Loop on items.
foreach ($items as $item) {
$_coder_upgrade_module_name = '';
// $_coder_upgrade_dirname = $item['old_dir'];
if (!isset($_SERVER['HTTP_USER_AGENT']) || strpos($_SERVER['HTTP_USER_AGENT'], 'simpletest') === FALSE) {
// Process the directory before conversion routines are applied.
// Note: if user agent is not set, then this is being called from CLI.
coder_upgrade_convert_begin($item);
}
// Call main conversion loop.
coder_upgrade_convert_dir($upgrades, $extensions, $item, $recursive);
// Apply finishing touches to the directory.
// Swap directories if files are replaced.
$new_dir = $_coder_upgrade_replace_files ? $item['old_dir'] : $item['new_dir'];
coder_upgrade_convert_end($new_dir);
// Make a patch file.
coder_upgrade_make_patch_file($item, $_coder_upgrade_replace_files);
}
return TRUE;
}