[dokuwiki] Re: events

  • From: Chris Smith <chris@xxxxxxxxxxxxx>
  • To: dokuwiki@xxxxxxxxxxxxx
  • Date: Tue, 18 Apr 2006 20:54:49 +0100

Andreas Gohr wrote:

I agree, a wrapper could be useful. This brings me to another point: If
I understand it correctly the constructor of the event object accepts a
function callback in the $fn parameter. This should not only accept a
string but also an array to allow to pass object methods...

see
http://www.php.net/manual/en/language.pseudo-types.php#language.types.callback
for what I mean.

If it already does - just ignore me ;-)
Yes and no.

Callbacks can only pass parameters by value. The event system needs to use parameters by reference, I guess I could have got around that by requiring the reference be placed in a carrier data type (e.g. an array), but I didn't think of that at the time :-), instead I check to see if the function is_callable, then if its an array, I split it into (object, method). This loses a little functionality over callbacks, you can't pass class names. I guess it can be changed to use a carrier data type.

For good example plugins, without moving any existing Dokuwiki functionality into a plugin, hmmm...

I think the best one will come from Esther, a discussion plugin, though we may need to convince her to release it separately from the blog plugin :-)

Cheers,

Chris




-- DokuWiki mailing list - more info at http://wiki.splitbrain.org/wiki:mailinglist

Other related posts: