We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 37007
    • 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.
        Mark Hamstra • Developer spending his days working on Premium Extras and a MODX Site Dashboard with the ability to remotely upgrade MODX and extras to make the MODX world a little better.

        Tweet me @mark_hamstra, check my infrequent blog at markhamstra.com, my slightly more frequent ramblings at MODX.today or see code at Github.
        • 37007
        • 4 Posts
        Thanks for the quick answer. I think the RunProcessor method was exactly what I was looking for.