Is there a consensus on how plugins should be implemented in a PHP application?
I've looked into the observer pattern which comes close, it's really just a notification system and doesn't allow code to extend the application directly. I'm currently using a simple hook systems that I came up with:
public function registerHook($hookName, array $params = array())
{
$this->hooks[] = $hookName;
foreach ( $this->plugins as $pluginName => $hooks ) {
if ( in_array($hookName, $hooks) ) {
$plugin = new $pluginName($this, $this->view, $this->controller);
$plugin->{$hookName}($params);
}
}
}
This works well for my purposes but I'm curious if there's a design pattern out there that has been tested and proven many times over and I'm just re-inventing the wheel.