Jump to content

Check if another module is attached


playdewu
 Share

Recommended Posts

Hi guys.

 

I'm trying to create my first module.

 

Can you give me advice how to check if the another module is attached to hook from my module install() function? Then if not, is possible to attach it?

Share this post


Link to post
Share on other sites

The Module class has a function named "isRegisteredInHook", where you pass the hook name

 

So in your install function, you can use the Module function getInstanceByName to get an instance of the other module, and then use isRegisteredInHook to see if the module is hooked

$othermodule = Module::getInstanceByName('module_name');
if (!$othermodule->isRegisteredInHook('hook_name'))
{
     //add your code to register the module to the hook, something like....
     $othermodule->registerHook('hook_name');
}

The above code is not tested, but should work

  • Like 1

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...

Important Information

Cookies ensure the smooth running of our services. Using these, you accept the use of cookies. Learn More