Please login or register.

Login with username, password and session length
  • * Welcome, Guest
September 07, 2010, 04:31:23 AM

News:

Coderzilla is back!

Author Topic: [Research] Hook System  (Read 151 times)

coolhome

  • I run this website!
  • Admin
  • Newbie
  • *****
  • Posts: 13
  • Addicted to coding!
    • MSN Messenger - PJAlva1@hotmail.com
    • View Profile
    • WWW
    • Email
[Research] Hook System
« on: July 09, 2009, 04:15:04 AM »
Hello. Today I was wondering how a hook system should work. If you dont know what a hook system its where you can 'hook' a function to the execution of another function. This would make it easier for developers to create plugin's and modifications.

Well I was creating some ideas on how you could possibly do it and I wanted to know if anyone else any ideas.

Idea 1 - Create a class named HookManager. This would class would have add_hook, run_hook, hook_exists, remove_hook.

Now when you create a function you would use global to get the hookmanager. Then at the topc of the function before anything starts add $hookmanager->run_hook("currFuncName", "before");
which will run all the functions for currFuncName before the function start.
Then at the end add $hookmanager->run_hook("currFuncName", "after");

Any other ideas?
Logged