Jump to content

Recommended Posts

Posted

Hello,

I'd like to extend an existing module, because I want to add functionality to a not hookable function. How can I achieve that my extended class is called first? 
Currently both modules are appearing in Setup menu, so the original one and the extended as well. I want to achieve that if I click on the original menu item, my extended class is called. 

Thank you for the answers!

Posted

Hey, pleini!

  1. This is not about extending a class, but maybe an easier way to do what you need.
  2. If you got a reasonable need to have some method hookable and a module is maintained, you can ask the author to make it hookable. All module writers I have talked to tried to help me when I asked and almost all of them were friendly doing that)
  • Like 1
Posted

Hi, thanks for the suggestions!
I think multiple copies of the same module is not the best solution, because it's not update safe. If they release an updated version of the module, we have to create a copy again.

Meanwhile I found a possible solution. They create the page for the Setup menu in the install() function of the original class. In the extended class I update the original page.

$page->name = self::pageName; 
$page->process = $this;

So the page process will be the extended class. What do you think about this solution?

Posted

Even overwriting only a single function (now rather two) is not really update save. It's less likely to change, but might still be subject to change.

  • Like 1

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
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...