Here i am going to create a customized hook. I wasted my hours on this but didn't get good answers that's why I decided to post this topic :-
For creating hook we need one of given function :
module_invoke_all
module_invoke
Step 1 : I created a module named custom_hooker and inside it's module file we have a custom hook this simply returns a value -
/*
* Creation of custom hook in module_name_hook_name form
*/
function custom_hooker_get_hooker_values() {
return "Rajat";
}
Step 2 : For calling the above given hook I created a new module named custom-
/*
* Implementation of hook_menu() only to create a url so that I can easily check the custom hook
*/
function custom_menu() {
$items['check-hook'] = array(
'title' => 'Custom check hook',
'page callback' => 'custom_check_hook',
'access arguments' => array('access content'),
'type' => MENU_NORMAL_ITEM,
);
return $items;
}
function custom_check_hook() {
custom_get_caller_values();
}
/*
* Custom hook call here we used module_invoke_all function and the hook name (get_hooker_values) as an argument
*/
function custom_get_caller_values() {
$all_values = module_invoke_all('get_hooker_values');
// now $all_values will have the return value of custom_hooker.
}
I hope this way will help you in creating custom hook for your own module.
Any suggestion & Comment are welcome.
Regards
Rajat Singh Gusain