[Solar-talk] App extensions
Rodrigo Moraes
rodrigo.moraes at gmail.com
Fri Jul 21 06:51:42 PDT 2006
Hi all.
I'm have a plan for a system and would like to hear opinions and
ideas, or how do you think it could fit it well in Solar. Basically, I
want to allow "extensions" (or "add-ons", or "plugins") for an app,
providing hooks inside it that would trigger some events. The idea is
to implement the Observer pattern, providing a mechanism to store
event subscriptions and tie them to Solar. The storage could be a
database, a cached file, a serialized array, etc., the details doesn't
matter right now. In any case, once Solar is initialized, it reads the
subscriptions and register() them, and then when a event is triggered,
the system looks for any extension subscribed to it, and if any, call
it etc.
For example, a call in layout _head.php: $this->event('head'); would
trigger an event, look for any extension subscribed to that event, and
if any would call it, which could for example add things to the layout
(e.g. include javascript or css).
Output something is easier - a helper could "talk" with the extension
system to see if there are subscriptions to the event. It would be a
"non-official" extra helper, added separately to the app. For other
event examples, like pre-login, post-login or "pre-send-content-type",
I have to look inside Solar to see if it is possible to add hooks
without changes.
Well, the idea is: once an app is done and well "hooked", you don't
need to make big changes in the core anymore - instead you will
include or change functionalities adding extensions to it.
I don't know exactly how to structure these extensions. It seems that
ideally each one should have its own directory inside the app - with
locale, view and layout subdirs, if needed. Also, perhaps there is
interest in create an unified API for this. Have anyone implemented
something similar with Solar?
Ah, I have found a related package in Pear: Event_Dispatcher [1]
Well, thoughts are welcome. :-)
cheers,
rodrigo moraes / brazil
[1] http://pear.php.net/package/Event_Dispatcher
More information about the solar-talk
mailing list