function coder_upgrade_cache_info_hooks in Coder 7
Same name and namespace in other branches
- 7.2 coder_upgrade/conversions/begin.inc \coder_upgrade_cache_info_hooks()
Caches hook_theme() and hook_menu() entries for the modules being converted.
Parameters
array $item: Array of a directory containing the files to convert.
1 call to coder_upgrade_cache_info_hooks()
- coder_upgrade_upgrade_begin_alter in coder_upgrade/
conversions/ begin.inc - Implements hook_upgrade_begin_alter().
File
- coder_upgrade/
conversions/ begin.inc, line 92 - Provides conversion routines applied to the directory before routines are applied to the files.
Code
function coder_upgrade_cache_info_hooks($item, $recursive = TRUE) {
global $_coder_upgrade_module_name, $_coder_upgrade_theme_registry, $_coder_upgrade_menu_registry;
static $ignore = array(
'.',
'..',
'CVS',
'.svn',
);
static $extensions = array(
'module',
'inc',
);
$dirname = $item['old_dir'];
// Determine module name.
coder_upgrade_module_name($dirname, $item);
$_coder_upgrade_module_name = $item['module'] ? $item['module'] : $_coder_upgrade_module_name;
// Find hook_theme and hook_menu for this module and cache the results.
$filenames = scandir($dirname . '/');
foreach ($filenames as $filename) {
if (!in_array($filename, $ignore)) {
if (is_dir($dirname . '/' . $filename)) {
if ($recursive) {
// TODO Fix this!!!
$new_item = array(
'name' => $item['name'],
'old_dir' => $dirname . '/' . $filename,
);
coder_upgrade_cache_info_hooks($new_item, $recursive);
// Reset the module name.
$_coder_upgrade_module_name = $item['module'];
}
}
elseif (in_array(pathinfo($filename, PATHINFO_EXTENSION), $extensions)) {
$values = array(
$_coder_upgrade_module_name . '_theme',
$_coder_upgrade_module_name . '_menu',
);
$cur = file_get_contents($dirname . '/' . $filename);
// Create reader object.
$reader = PGPReader::getInstance();
coder_upgrade_memory_print('create reader for file ' . $filename);
$reader
->setSnippet($cur);
// $reader->addTokenNames(); // @todo This is unnecessary.
if (FALSE) {
$reader
->buildGrammar();
coder_upgrade_memory_print('build grammar');
}
else {
$reader
->buildSpecific(T_FUNCTION, $values);
coder_upgrade_memory_print('build specific grammar');
}
$functions = $reader
->getFunctions();
foreach ($functions as $function) {
// cdp("name = {$function->data->name}");
if ($function->data->name == $_coder_upgrade_module_name . '_theme') {
$module_theme = @eval($function->data->body
->toString());
foreach ($module_theme as $key => &$value) {
$value['variables'] = isset($value['arguments']) ? $value['arguments'] : array();
unset($value['arguments']);
// $module_theme[$key] = $value;
}
$_coder_upgrade_theme_registry = array_merge($_coder_upgrade_theme_registry, $module_theme);
// break 2;
}
elseif ($function->data->name == $_coder_upgrade_module_name . '_menu') {
coder_upgrade_convert_return($function->data->body, 'menu', '', 1, 1);
// break 2;
}
}
// Free up memory.
$reader
->reset();
coder_upgrade_memory_print('reset reader');
}
}
}
}