I have a need to implement my own modSnippet class, I can implement the class I want, derived from modScript so we keep the hierarchy intact but how do I tell the framework that I want this class loaded and not ModSnippet. What’s the best way to do this?
Use MODx, or the cat gets it!
Ok ta.
Its just a little extension for modxfs-php. At the mo the loadScript function in the modScript class ’eval’s’ the script code, I want to update this so that if a user is using modxfs-php a check is made and the script is ’included’ instead. We can do this as the script is a normal file system file as far as MODx is concerned, like any other external php script. This allows the user to open the script in his IDE and set breakpoints etc. as you would with any externalised script. So, we can debug snippets that really only exist in the database.
I guess I was looking for a generalised mechanism that allows a core class to be installed via package manager and updates a setting somewhere to say ’dont use core modSnippet’, use my modSnippet instead’ a sort of class registery system if you like.
Use MODx, or the cat gets it!
-
MODX Staff
- 10,725 Posts
We will be heading to where you can register derivatives for various parts of the core more easily; we’re just not there yet, at least not for modElement classes. In fact, a lot of things will be changing after 2.0.x as far as the data structures behind Resources and Elements are concerned which will be affecting these capabilities significantly.
For now, I suggest creating an include Snippet that encapsulates this. It becomes one function to call all of your file-system based Snippets, and you can include them however you want.
Fair enough, using the include method’s OK till we can do this in the future.
Use MODx, or the cat gets it!