function module_builder_process_hook_data in Module Builder 7
Same name and namespace in other branches
- 6.2 includes/process.inc \module_builder_process_hook_data()
Builds complete hook data array from downloaded files and stores in a file.
Parameters
hook_file_data: An array of data about the files to process, keyed by (safe) filename: [MODULE.FILENAME] => Array // eg system.core.php [path] => full path to the file [destination] => %module.module [group] => GROUP // eg core [hook_destinations] => array(%module.foo => hook_foo, etc) This is the same format as returned by update.inc.
Return value
An array keyed by originating file of the following form: [GROUP] => array( // grouping for UI. [{i}] => array( [name] => hook_foo [definition] => function hook_foo($node, $teaser = FALSE, $page = FALSE) [description] => Description. [destination] => Destination module file for hook code from this file.
1 call to module_builder_process_hook_data()
- module_builder_update_data in includes/
common.inc - Update hook files and process them to our data file.
File
- includes/
process.inc, line 139 - Module builder code processing code.
Code
function module_builder_process_hook_data($hook_file_data) {
/*
// Get list of hook documentation files
$files = module_builder_get_doc_files($directory);
if (!isset($files)) {
return NULL;
}
*/
//print_r($hook_file_data);
// check file_exists?
// Build list of hooks
$hook_groups = array();
foreach ($hook_file_data as $file => $file_data) {
$hook_data_raw = _module_builder_process_hook_file($file_data['path']);
$file_name = basename($file, '.php');
$group = $file_data['group'];
// Create an array in the form of:
// array(
// 'filename' => array(
// array('hook' => 'hook_foo', 'description' => 'hook_foo description'),
// ...
// ),
// ...
// );
foreach ($hook_data_raw['names'] as $key => $hook) {
// The destination is possibly specified per-hook; if not, then given
// for the whole file.
if (isset($file_data['hook_destinations'][$hook])) {
$destination = $file_data['hook_destinations'][$hook];
}
else {
$destination = $file_data['destination'];
}
$hook_groups[$group][$key] = array(
'name' => $hook,
'definition' => $hook_data_raw['definitions'][$key],
'description' => $hook_data_raw['descriptions'][$key],
'destination' => $destination,
);
//dsm($hook_groups);
}
// foreach hook_data
}
// foreach files
//dsm($hook_groups);
//print_r($hook_groups);
// Write the processed data to a file.
$directory = _module_builder_get_hooks_directory();
file_put_contents("{$directory}/hooks_processed.php", serialize($hook_groups));
return $hook_groups;
}