View Single Post
Old 02-22-2009, 06:38 AM   #2 (permalink)
jlodell
The Wanderer
 
Join Date: Feb 2009
Posts: 7
Thanks: 0
jlodell is on a distinguished road
Default Quick and dirty

First, the actual registration of the plugin is missing.
It just includes the plugin class file.
Try this as your registerplug method.

function registerplug($plugin){
// if the plugin isn't already registered
if(!array_key_exists($plugin,$this->plugin)){
// include library file
require_once($this->fullpath.
"/plugins/$plugin/$plugin.plugin.php");
// create instance of plugin
$this->plugin[$plugin] = new $plugin;
}
return $this;
}

And this for the hook method...

function hook($checkpoint){
// Cycle through all the plugins that are active
foreach($this->plugins as $key=>$plugin){
if(!method_exists($plugin,$checkpoint)){
throw new Exception("Cannot hook plugin($key) at checkpoint ($checkpoint)");
}
$this->results[$key] = $plugin->$checkpoint();
}
}

This is just real dirty implementation on what you already have. There are better ways to go about this. some shortcomings include the fact that method exists will show private and protected members which cannot be called like this.
This should make this work and get you moving in the right direction though.

I would pick a common PHP framework and read thru some of the library files that implement similar behavior to get a little inspiration.

cheers,
justin
jlodell is offline  
Reply With Quote
The Following User Says Thank You to jlodell For This Useful Post:
Jonnee (02-22-2009)