vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=15)
-   -   Hooks inside classes (https://vborg.vbsupport.ru/showthread.php?t=140123)

Pyrix 02-22-2007 10:17 AM

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

Marco van Herwaarden 02-23-2007 10:30 AM

.....but i get errors.....

It might help if you show the errors.

Adrian Schneider 02-23-2007 01:39 PM

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 :(

Pyrix 02-24-2007 08:58 AM

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


All times are GMT. The time now is 11:10 PM.

Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.00898 seconds
  • Memory Usage 1,712KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (4)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • printthread_start
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete