Skip to content
Advertisement

Delegating the hook handler of a module M in a class C doesn’t work: this handler is not triggered

Consider this Prestashop 1.7 module M:

JavaScript

As you can see, I give its instance to a class C. The latter’s code is:

JavaScript

The expected behavior’d be: if I create a customer in Prestashop, then the dump is executed and so is the exit, resulting in a blank page with the text of the dump.

The actual behavior is: if I create a customer in Prestashop, then the dump is not executed, the exit isn’t too, resulting in the customers list page with the newly created customer and a notification telling me that the new customer has been created.

The expected behavior can be obtained by not using the class C and by moving the code of the latter within the class M. However, I really want to delegate to C, for lisibility and maintenability purposes.

How could I do it? Why doesn’t it work?

Advertisement

Answer

This is a better way I think:

JavaScript

tip: your “registerHook” function should not be at the constructor. It must be in the Install function.

User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement