0

I was wondering if using hook_module_implements_alter() is a good practice in D8 also to alter the order of execution of hooks?

I came to hear that it is suggested to do this with events that was introduced in D8 which will be a better way, but I could not find any reference that says not to use hook_module_implements_alter() in D8. One such ref.

If using events is advised, can someone put up a small example as to how to do that?

Thanks

1

I was wondering if using hook_module_implements_alter() is a good practice in D8 also to alter the order of execution of hooks?

Yes it is - in fact it's the only way to alter the order of hook execution.

Events are something different. Their execution order is set in the implementation of each handler, and can't be affected by any hook.

  • 1
    "Yes it is - in fact it's the only way to alter the order of hook execution.". There's a second way and that's the module weight, which is the default execution order of hooks (weight, then alphabetically). But hook_module_implements_alter() is more flexible – Berdir Jun 27 '18 at 22:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.