Jump to content

Observer Notifier - Replace Not Add To Code Snippet


gjh42

Recommended Posts

I have been studying about OOP coding in preparation for my e-commerce platform moving to a new version where it will be required for mod authors. The platform currently has an override system which detects modified versions of files in an override folder, and uses them instead of the original file. One thing I have not been able to find mention of anywhere on the net is how to substitute a new section of code for an original core file's code (for a modified functionality) using the observer-notifier system.Generally, my understanding is that when the observer is triggered, it executes the desired code and returns to the triggering point to continue.This will not work for the kind of thing I (and many others) will need to do, which is to execute a snippet of code instead of a snippet in the core file. If the observer returns to the triggering point, the original code will execute. I need it to return to another point after the original snippet, bypassing it.This effect must be possible, as the developers would not be expecting us to use the method otherwise. Perhaps it is handled in a fashion so different from procedural code that it is not apparent to the untrained that it will happen.Can anyone enlighten me on how this code substitution would work?

Link to comment
Share on other sites

This is just a poor man's event model basically. They have a way to register an event handler for a particular event, and then a way to fire an event so that the event handlers execute for that event. If you want it to execute a certain piece of code instead of another piece of code, then they would have to register their piece of code as an event handler and your event handler would have to somehow tell it to not execute the default handler (i.e., return false or whatever). If their system isn't already set up like that then you can't change how that works with just your code, you would need to change the event model so that it supports default events and then convert all of their code into the default event handlers.

Link to comment
Share on other sites

Obviously I'm not going to rewrite the e-commerce application's coding structure. If default event handling is necessary for the kind of substitution I am looking for, I suppose it will be built into the structure of the new version, as substituting custom code for stock code is at the heart of the override concept. I will have to ask the devs, since this is not apparently a standard PHP/OOP task that can be simply explained with code examples that will be generally applicable.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...