-
- 4 Posts
Hi!
I'm currently developing a media management package for MODx that relies heavily on AJAX requests. Lately, I have found myself duplicating a lot of code in my processors, as the tasks that they need to perform are fairly similar.
Now I'm looking for ways to introduce some object-oriented features into my processors, but the way they are set up seems to promote procedural coding. I'm fairly new to MODx, being introduced to it only a couple of weeks ago, so I'd really appreciate your input on this one.
What is the best way of setting up inheritance between different processors?
Thanks for your answers in advance.
Jester
Typically if there's a certain task that needs to be done (preparing posted data in one way or another, parsing data through shared templates etc) that can easily be abstracted into your package's class.
In terms of inheritance, you could use $modx->runProcessor (
http://rtfm.modx.com/display/revolution20/Using+runProcessor) to execute another processor. Or simply include it.
You can also override your item's save() (or others) function to make it parse any data the way you need it to in its own class file.
-
- 4 Posts
Thanks for the quick answer. I think the RunProcessor method was exactly what I was looking for.