Jump to content

Double override


Radu

Recommended Posts

assuming you do not try to override the same functions, that should work ok.

 

you would really be better off to fail during the module install, and provide a message to the user as to why it failed. then offer to merge the files together properly.

Link to comment
Share on other sites

This for us seems one of the rather larger issues we face today as module developers.

assuming you do not try to override the same functions, that should work ok.

 

you would really be better off to fail during the module install, and provide a message to the user as to why it failed. then offer to merge the files together properly.

 

We are for one not terribly comfortable with existing override handling in prestashop.

 

For example: module (1) is installed,

Creates a backup of the original override

Then either modifies an existing ovrerride or copies in it's override.

 

Module (2) is installed and creates it's own back up and override.

Customer then decides to upgrarde or remove Module(1) via uninstall

Module (1) doesn't know that it's backup of the override is now out of date, i.e. uninstall will copy it's original backup of the override and replace the product version.

Module (2) is now malformed.

 

You can program a lot of stop logic into Module 1, but you have no control over Module 2's logic.

 

if you could use overrides with different names than the parent, most of the install/uninstall problems would be resolved. This doesn't keep one from messing up another modules override but at least makes load/fallback easier.

 

For example: You could then have an override fille named

ConfigurationMyModule

that:

class Configuration extends ConfigurationCore

Link to comment
Share on other sites

  • 6 months later...

Thank you for replies, for some reason I wasn't receiving updates of the post, I changed the setting accordingly now.

 

Still not perfect but in presta 1.5 the merging is done automatically if the modules don't override the same method.

I guess the hooks especially dynamic hooks are a good solution, for now dynamic hooks are at their beginning.

 

Anyway it really depends on the module but I too don't feel comfortable to override a method especially it's a big chunk of code making it very probable other module will overwrite it.

 

Elpatron,

For your modules do you offer an automatically way to merge the overrides?

Link to comment
Share on other sites

Thank you for replies, for some reason I wasn't receiving updates of the post, I changed the setting accordingly now.

 

Still not perfect but in presta 1.5 the merging is done automatically if the modules don't override the same method.

I guess the hooks especially dynamic hooks are a good solution, for now dynamic hooks are at their beginning.

 

Anyway it really depends on the module but I too don't feel comfortable to override a method especially it's a big chunk of code making it very probable other module will overwrite it.

 

Elpatron,

For your modules do you offer an automatically way to merge the overrides?

\

 

I looked at merging...but now I just avoid overrides at all costs. I've rewritten my modules to remove overrides where ever possible.

Link to comment
Share on other sites

Elpatron,

thank you for your answer, I was checking the traits but I don't see how it can help, basically traits are same methods shared by multiple classes.

 

for presta we search to override same method by multiple times

 

Still hooks/some similar mechanism to alter function output/return values like "filters" I saw a similar system for shopware ecommerce engine. They had hooks and filters

 

Maybe I don't see all the details...

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...