function _module_builder_process_hook_file in Module Builder 7
Same name and namespace in other branches
- 6.2 includes/process.inc \_module_builder_process_hook_file()
Extracts raw hook data from downloaded hook documentation files.
Parameters
string $path: Path to hook file
string $file: Name of hook file
Return value
array Array of hook data: [0]: Each hook's user-friendly description [1]: Each hook's entire function declaration: "function name($params)" [2]: Name of each hook
1 call to _module_builder_process_hook_file()
- module_builder_process_hook_data in includes/
process.inc - Builds complete hook data array from downloaded files and stores in a file.
File
- includes/
process.inc, line 252 - Module builder code processing code.
Code
function _module_builder_process_hook_file($filepath) {
$contents = file_get_contents("{$filepath}");
// Get the destination stored at the top of the file.
preg_match('[^// module builder: (\\S+)\\n]', $contents, $matches_dest);
$destination = $matches_dest[1];
// The pattern for extracting function data: capture first line of doc,
// function declaration, and hook name.
$pattern = '[
/ \\* \\* \\n # start phpdoc
\\ \\* \\ ( .* ) \\n # first line of phpdoc: capture the text
(?: \\ \\* .* \\n )* # lines of phpdoc
\\ \\* / \\n # end phpdoc
( function \\ ( hook_\\w* ) .* ) \\ { # function declaration: capture both entire declaration and name
]mx';
preg_match_all($pattern, $contents, $matches);
// We don't care about the full matches.
//array_shift($matches);
$data = array(
'descriptions' => $matches[1],
'definitions' => $matches[2],
'names' => $matches[3],
'destination' => $destination,
);
return $data;
}