I try to implement hook_menu()
in a module and the code inside of this hook depends on another hook implemented in the same module Example:
function mymodule_menu() {
$streamwrapper = file_stream_wrapper_get_instance_by_scheme('myscheme');
if($streamwrapper !== false) {
$directory = $streamwrapper->getDirectoryPath();
.....
}
}
and another hook function in the same (mymodule) module
function mymodule_stream_wrappers() {
retunr array( 'myscheme' => array(...)
}
Apparently, hook_stream_wrappers()
is called after hook_menu()
, and file_stream_wrapper_get_instance_by_scheme()
returns false
during module installation process.
So, the whole idea works because Drupla will call hook_menu
eventually and by that time stream wrapper will be in place and ready, but it seems too unreliable, IMHO.
Anyway, is it possible to control hooks order somehow? Or is there a better way to achieve desired result - retrieve stream wrapper in hook_menu after is has been known by the system?