Jump to content

Access to legacy Module instance within Symfony service or controller


Recommended Posts

Hello guys,

 

I would like to register a new hook from a symfony service or controller of my module. To do this I need the Module instance. I tried this code:

 

$module = $this->get('prestashop.adapter.legacy.module')->getInstance();
$module->registerHook(....);

 

But for some reason the getInstance() method returns null. Am I doing something wrong ? I saw a ->getInstanceById method but it feels weird to me that the symfony code knows the module id

 

I found a workaround using hooks. I dispatch a custom hook in my symfony code, and in my main module class, I register a new hook within the hook method because I have access to the module right here. But I don't like this solution very much I would rather register the hook directly from symfony.

 

Thank you

Link to comment
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
×
×
  • Create New...