Dec 08 2005

Hook system

Category: phpMUR - What I'm doingerm @ 11:52 pm

I think I’ve devised a way to have a hook system for every function in the class.

This is a concept.

Here goes.

In theory this might blow up in my face.

In php there is a way to get the current function you’re in __FUNCTION__, I believe there’s also away to get the current class you’re in by using __CLASS__

So what I could do:

Create a function called.
call_hooks(__FUNCTION__, $args);
Args will more than likely be specific to what that function returns. Most functions I have return arrays, strings, or bool. In fact … that’s exactly what they return, and it would only call the hooks on successful situations.
set_hooks(‘song_change’,’function_name’); is how I plan on setting it up.

I think I better get to work on this idea. Seems like either a borked thing to do, or a really smart thing to do.

Erm

One Response to “Hook system”

  1. erm says:

    I created a hook system and it seems to be working nicely. It’s easier to add a call_hook(__FUNCTION__,$args); to just the functions I need it to be. Also it saves a bunch of coding. Because I don’t have to worry about a adding 2 functions for every function I want a hook.

    I’ve successfully used it in log.php, scan.php, and osd plugins.

    Erm

Leave a Reply

You must be logged in to post a comment. Login now.