function _module_builder_process_hook_file in Module Builder 6.2
Same name and namespace in other branches
- 7 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}");
// 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],
);
return $data;
}