Anyway, there's the inspiration. A few weeks ago I had thought that it would be easier to have an XML file control the event hooking, like WoW does, but that got kind of silly when I realized that the control would be split across the XML and extension code, and I'd have to figure out the XML DOM. Then I realized that the most basic use of the thing would essentially be exactly the same across extensions, I dropped it.
So today, I decided it wouldn't be too much of a loss if I defined the function once in such a manner that it gets the class type of the incoming event, looks for a function of the same name in the extension class, and calls that (passing the event along, of course.)
So there. Simple Extension creates another abstract of the Extension class, and does just that, as well as make the theme object, and so far it seems to work pretty well.
To use, install by uncompressing the archive into
contrib/
and activate by creating a symlink in ext/
to contrib/!simple_extension
or by using the Extension Manager. Until a dependency resolution system is created, removing the exclamation mark fromAfter that, make a new extension, but instead of "
class hello_world implements Extension
" use "class hello_world extends SimpleExtension
" and then write methods like this to use events:
public function PageRequestEvent(Event $event) {
// PageRequestEvent code here
}
GitHub repository
Commit at time of post: 13434a2c
Dependencies:
No comments:
Post a Comment