Register Members List Search Today's Posts Mark Forums Read

Reply
 
Thread Tools
  #1  
Old 22 Feb 2007, 12:17
Pyrix Pyrix is offline
 
Join Date: Jul 2004
Hooks inside classes

Hey all,

I'm writing a fairly advanced plugin that i want to be 'extensible' by other people after it's released. I therefore want to include a hook inside the class i'm writing which can be used to add additional functions. I've created the hook with the xml file, and am now trying to add the hook to the class.

I've tried adding it to the class, outside of any functions, but i get errors, so I'm assuming the hook would have to go inside a function. Is it possible to do what i want? I want other plugins to add functions within my code by 'inserting them' at the hook. Should I put it inside the constructor? Or is it a lost cause?

Ollie
Reply With Quote
  #2  
Old 23 Feb 2007, 12:30
Marco van Herwaarden Marco van Herwaarden is offline
 
Join Date: Jul 2004
.....but i get errors.....

It might help if you show the errors.
__________________
Marco van Herwaarden
Ex vBulletin.org Coordinator
Reply With Quote
  #3  
Old 23 Feb 2007, 15:39
Adrian Schneider's Avatar
Adrian Schneider Adrian Schneider is offline
 
Join Date: Jul 2004
You can't add anything inside the class (outside of functions) that isn't related to the class. Take a look at the aggregate_methods() function but note that it's experimental and was dropped in PHP 5
__________________
Sr Software Developer / Tech Lead
Reply With Quote
  #4  
Old 24 Feb 2007, 10:58
Pyrix Pyrix is offline
 
Join Date: Jul 2004
I've found a sort of way of doing it... it seems a bit dodgy though.

I've put the hook inside the constructor, and it does work, but the functions get added globally, and do not become members of the class.. for example you have to call them using just myFunctionName() and not $this->myFunctionName()

Can anyone think of a better solution or am I stuck with using that? :P

Ollie
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


New To Site? Need Help?

All times are GMT. The time now is 03:25.

Layout Options | Width: Wide Color: